home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / programm / 5830 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  1.9 KB

  1. Path: sparky!uunet!usc!cs.utexas.edu!swrinde!gatech!emory!sol.ctr.columbia.edu!ira.uka.de!uni-heidelberg!rz.uni-karlsruhe.de!ma2s3!haible
  2. From: haible@ma2s3.uucp (Bruno Haible)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: format of floating points?
  5. Date: 5 Jan 1993 16:02:01 GMT
  6. Organization: University of Karlsruhe, Germany
  7. Lines: 35
  8. Sender: <haible@ma2s2.mathematik.uni-karlsruhe.de>
  9. Message-ID: <1icbdpINNsj1@nz12.rz.uni-karlsruhe.de>
  10. References: <YQH0P2M@math.fu-berlin.de>
  11. NNTP-Posting-Host: ma2s3.mathematik.uni-karlsruhe.de
  12. Summary: IEEE double float format
  13. Keywords: binary, float, double, IEEE standard
  14.  
  15. melchers@Harpo.Chemie.FU-Berlin.DE (Bernd Melchers) asks:
  16. > How are doubles coded by the ieee standard?
  17. >
  18. > 0.44658343480 is coded as ...
  19. > On a iris4d (big endian), the same double gives (ieee standard)
  20. > 3f dc 94 d2 af d9 af b1, i.e.
  21. > 0011 1111 1101 1100 1001 0100 1101 0010 1010 1111
  22. > 1101 1001 1010 1111 1011 0001
  23. > where is mantissa and exponent and how are they coded?
  24. >
  25.  
  26. Write down your number as a rational (Lisp function RATIONAL).
  27. It is equal to 8044931962220465/18014398509481984, i.e.
  28. 11100100101001101001010101111110110011010111110110001_binary / 2^54
  29. or 1C94D2AFD9AFB1_hexadecimal / 2^54 .
  30.  
  31. Either:
  32.   Bit 63 (leftmost) is the sign, bits 62 to 53 are 511 + exponent 
  33.   (exponent(x) = floor(log(abs(x))/log(2)), here exponent = -1, 
  34.   therefore 511-1 = 0111111110_binary), and bits 52 to 0 are the mantissa. 
  35. Or:
  36.   Bit 63 (leftmost) is the sign, bits 62 to 52 are 1024 + exponent
  37.   (exponent(x) = floor(log(abs(x))/log(2)), here exponent = -1,
  38.   therefore 1024-1 = 01111111101_binary), and bits 51 to 0 are the mantissa
  39.   with bit 52 hidden (because the mantissa is between 2^52 and 2^53 for
  40.   all nonzero floats).
  41.  
  42. Use another float to decide which case is correct.
  43.  
  44. Beware: the encoding of denormalized floats, NaNs and infs is a bit more
  45. complicated.
  46.  
  47. Bruno Haible
  48. haible@ma2s2.mathematik.uni-karlsruhe.de
  49.  
  50.