home *** CD-ROM | disk | FTP | other *** search
- 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
- From: haible@ma2s3.uucp (Bruno Haible)
- Newsgroups: comp.unix.programmer
- Subject: Re: format of floating points?
- Date: 5 Jan 1993 16:02:01 GMT
- Organization: University of Karlsruhe, Germany
- Lines: 35
- Sender: <haible@ma2s2.mathematik.uni-karlsruhe.de>
- Message-ID: <1icbdpINNsj1@nz12.rz.uni-karlsruhe.de>
- References: <YQH0P2M@math.fu-berlin.de>
- NNTP-Posting-Host: ma2s3.mathematik.uni-karlsruhe.de
- Summary: IEEE double float format
- Keywords: binary, float, double, IEEE standard
-
- melchers@Harpo.Chemie.FU-Berlin.DE (Bernd Melchers) asks:
- > How are doubles coded by the ieee standard?
- >
- > 0.44658343480 is coded as ...
- > On a iris4d (big endian), the same double gives (ieee standard)
- > 3f dc 94 d2 af d9 af b1, i.e.
- > 0011 1111 1101 1100 1001 0100 1101 0010 1010 1111
- > 1101 1001 1010 1111 1011 0001
- > where is mantissa and exponent and how are they coded?
- >
-
- Write down your number as a rational (Lisp function RATIONAL).
- It is equal to 8044931962220465/18014398509481984, i.e.
- 11100100101001101001010101111110110011010111110110001_binary / 2^54
- or 1C94D2AFD9AFB1_hexadecimal / 2^54 .
-
- Either:
- Bit 63 (leftmost) is the sign, bits 62 to 53 are 511 + exponent
- (exponent(x) = floor(log(abs(x))/log(2)), here exponent = -1,
- therefore 511-1 = 0111111110_binary), and bits 52 to 0 are the mantissa.
- Or:
- Bit 63 (leftmost) is the sign, bits 62 to 52 are 1024 + exponent
- (exponent(x) = floor(log(abs(x))/log(2)), here exponent = -1,
- therefore 1024-1 = 01111111101_binary), and bits 51 to 0 are the mantissa
- with bit 52 hidden (because the mantissa is between 2^52 and 2^53 for
- all nonzero floats).
-
- Use another float to decide which case is correct.
-
- Beware: the encoding of denormalized floats, NaNs and infs is a bit more
- complicated.
-
- Bruno Haible
- haible@ma2s2.mathematik.uni-karlsruhe.de
-
-