home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pascal / 6614 < prev    next >
Encoding:
Internet Message Format  |  1992-11-15  |  1.7 KB

  1. Path: sparky!uunet!ogicse!psgrain!qiclab!leonard
  2. From: leonard@qiclab.scn.rain.com (Leonard Erickson)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: Storage of Microsoft Reals.
  5. Keywords: Real,Microsoft,TurboPascal
  6. Message-ID: <1992Nov16.045729.26623@qiclab.scn.rain.com>
  7. Date: 16 Nov 92 04:57:29 GMT
  8. Article-I.D.: qiclab.1992Nov16.045729.26623
  9. References: <Hendrik.Klompmaker.5.721426727@beheer.zod.wau.nl>
  10. Reply-To: Leonard.Erickson@f51.n105.z1.fidonet.org
  11. Organization: SCN Research/Qic Laboratories of Tigard, Oregon.
  12. Lines: 27
  13.  
  14. Hendrik.Klompmaker@beheer.zod.wau.nl (Hendrik.Klompmaker) writes:
  15.  
  16. >A friend asked me about the format of microsoft (quick basic) real in a 
  17. >file. He needs to read a binary file in TP (wich uses IEEE reals) but doesn'
  18. >t know how the reals are stored. The files are written bye Qbasic.
  19.  
  20. QuickBasic normally uses the same IEEE formats that TP does. But the
  21. *older* format used by GWBASIC (and BASIC/BASICA) is different.
  22.  
  23. The best way to describe it is to say that it's the same as the TP
  24. 6-byte "REAL" format, except that the "sign/expoment" byte is at the
  25. other end. 
  26.  
  27. TP reals are 5 bytes of "mantissa" followed by an exponent byte.
  28. Miscrosoft single-precision is an expoment byte, followed by 3 bytes
  29. of mantissa. And MS Doubles are an exponenet byte followed by 7 bytes
  30. of mantissa. The format of the exponent bytes for all three is the same.
  31. And the mantissas only differe in length. 
  32.  
  33. So you can convert by simply shuffling a few bytes around and either
  34. truncating the mantissa or tacking some zero bytes onto the end as "padding".
  35.  
  36. -- 
  37. Leonard Erickson              leonard@qiclab.scn.rain.com
  38. CIS: [70465,203]             70465.203@compuserve.com
  39. FIDO:   1:105/51     Leonard.Erickson@f51.n105.z1.fidonet.org
  40. (The CIS & Fido addresses are preferred)
  41.