DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
ANSI implementation-defined behavior

Floating point

This section describes the implementation-defined characteristics of floating point numbers. It corresponds to section ``F.3.6 Floating Point'' in the ANSI document.

Floating-point range and representation

The representations and sets of values of the various types of floating-point numbers in the compiler are:


float
4 byte IEEE format

double
8 byte IEEE format

long double
12 byte IEEE format


NOTE: The section ``C Implementation Limits description'', later in this appendix, presents the range of values each floating point type can take on.

Converting an integer to a floating-point

An integral value is truncated to the nearest floating-point representation if it cannot be converted exactly.

Converting a floating-point to a narrower floating-point

When a floating-point number is converted to a narrower floating-point number, the direction of truncation or rounding is towards the nearest floating-point number.

An overflow causes a run-time exception to occur. For example:

   double d;
   float f;
   

main() { d = 1.2345e300; f = d; /* dumps core */ }

If an underflow occurs, the value is rounded towards 0.
Next topic: Arrays and pointers
Previous topic: Integers

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003