GEOS SDK TechDocs
|
|
4 Direct FP Operations
|
4.2 The Floating Point Stack
The Math Library defines floating point numbers by using binary point representation. In this format the bit in the zeros place is multiplied by 20, the bit in the minus-ones place is multiplied by 2-1, etc. The exponent is in base 2. For example, the Binary Point representation for 5 is:.
Floating Point Numbers in GEOS follow the IEEE 754 standard used by Intel. In this format a floating point number is represented in an 80 bit (5 word) format. (In C, this type is known as a
long
double
.) This format specifies that the 80 bits contain:
The 15 bit exponent is biased by 3FFFh, so that an exponent of 1 would be represented by 4000h, and an exponent of -1 would be represented by 3FFEh. This produces a hexadecimal range for the exponent of 4000h, or a decimal range of 4932.
Infinity is represented by 7FFFh in the exponent and 1 followed by 63 zeros in the mantissa. Therefore, all exponent bits are set to 1. (Negative infinity is the same except that the sign bit is also set to 1).
Zero is a special case in which all 80 bits-- sign, exponent, and mantissa--are set to zero.
The mantissa is normalized so that the most significant bit is always 1 (except when the FP number is zero). The binary point follows this 1 bit. This produces a precision of approximately 19 decimal places, which is adequate for most needs. This most significant bit is not "assumed away"; it is always present in the mantissa.
Note that in most uses, the use of binary point representation is transparent to the application.
GEOS SDK TechDocs
|
|
4 Direct FP Operations
|
4.2 The Floating Point Stack