[futurebasic] Re: [FB] Floating point question

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1999 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Thu, 23 Sep 1999 13:48:47 +1200
>I am a little confused about the format of floating point numbers in FB^3.
>Are the floating point values defined with the "#" symbol extended presision
>(10 bytes per number) or double presision (8 bytes per number)?
>
>Are single precision floating point numbers 4 bytes per number or 8 bytes per
>number? This quote from the conversions manual seems to imply that they are 8
>bytes but that seems wrong to me: "When saving single precision floats, both
>PPC and SANE (but not FutureBASIC II) use the same 8 byte structure and these
>may be saved as numeric values."

From "FB^3 Reference"  II.1  Real Number literals
* Standard notation : <snip>  Examples: 17.3 -62. 0.03
* Scientific notation : <snip>   Examples: 3e-20 -6.7E4 0.05E+14

There's no mention of preceding a real literal with #. As it happens,the
FB^3 compiler does accept a literal of the form #3.1, for no good reason
that I can think of, but the # is evidently ignored. That's different from
FBII, where the preceding # signalled the (otherwise virtually unsupported)
SANE extended type.

The internal storage of floating point numbers in FB^3 is as follows:-

                    68K                       PPC
single!         4 bytes SANE single      4 bytes IEEE 754 single
double#        10 bytes SANE extended    8 bytes IEEE 754 double

SANE and IEEE 754 singles are identical. In your quote above, there is a
documentation error: "use the same 8 byte structure" should be "use the
same 4 byte structure".

HTH,

Robert