TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: LAWRENCE GORDON
from: ERIC SCHONNING
date: 1996-07-07 00:00:00
subject: Re: Reading Pascal Files

I found some problems with the routine, so here are the fixes.  It
should work fine now.  I also changed the name of the function to 
CVPR, for ConVert Pascal Real, as it makes more sense that way.
    Eric
 
 
'written by Eric Schonning
'can be reached at Fido 1:206/2512 or email hbcsc388@huey.csun.edu
'released to public domain 7/4/96
 
p$=chr$(130,34,23,41,34,0)
print cvpr(p$)
 
function cvpr(pas6$)
'get value of 6 byte pascal REAL.   cvpr=convert pascal real
dim i as integer
dim mantissa as quad
dim exponent as single
dim sign as integer
'pascal real value can range from 2.9x10^-39 to 1.7x10^38.
'single precision range is 8.43x10^-37 to 3.37x10^38.
 
if len(pas6$)  6 then exit function  'must be 6 bytes to convert
 
'pascal real: 48 bits (6 bytes * 8 bits/byte)
's=sign bit
'47 46           8 7           0
'  s    mantissa      exponent
 
'1st byte is exponent, other 5 are the mantissa.
pas6.exponent$=left$(pas6$,1)
pas6.mantissa$=right$(pas6$,5)
 
if asc(pas6.exponent$)=0 then cvpr=0:exit function
exponent=2^(asc(pas6.exponent$)-129)
 
'the mantissa is a 39 bit unsigned integer
for i=1 to 5
  m?=asc(mid$(pas6.mantissa$,i,1))
  if i=5 then sign=bit(m?,7):bit reset m?,7
  incr mantissa,m?*16^((i-1)*2)
next i
 
cvpr=(-1)^sign*exponent*(1+mantissa/2^39)
 
end function
--- QM v1.00
---------------
* Origin: Creekside Manor (805) 484-8016 CdCom Support BBS (1:206/2512.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.