roundConstFp Code Generation Option (AIX)

Syntax: Default:
gen(roundConstFp, nearest)
gen(roundConstFp, minusinf)
gen(roundConstFp, plusinf)
gen(roundConstFp, zero)
gen(roundConstFp, nearest)

This option controls the compile-time rounding mode of constant floating point expressions. It does not affect run-time rounding.

By default, constant floating-point expressions are rounded toward the nearest representable number at compile time.

The following table describes the effect of specifying gen(roundConstFp, option) for each of the roundConstFp suboptions.

Option Effect
nearest Round to nearest representable number.  This is the default.
minusinf Round toward minus infinity.
plusinf Round toward plus infinity.
zero Round toward zero.

Compile-time floating-point arithmetic can have two effects on program results:

In general, code that affects the rounding mode at run time should be compiled with the roundConstFp option that matches that rounding mode. For example, when the following program is compiled, the expression 1.0/3.0 is folded at compile time into a double-precision result:

main()
{
	float x, y;
	int i;
	x = 1.0/3.0;
	i = *(int *)&x;
	printf("1/3 = %.8x\n", i);
	x = 1.0;
	y = 3.0;
	x = x/y;
	i = *(int *)&x;
	printf("1/3 = %.8x\n", i);
}

This result is then converted to single precision and stored in float x. 

The gen(float, fold, no) option can be specified to suppress all compile-time folding of floating-point computations.  For example, the following code fragment may be evaluated either at compile time or at run time, depending on the setting of opt(level), gen(float, fold), and other options:

	x = 1.0;
	y = 3.0;
	x = x/y;

The gen(roundConstFp) option only affects compile-time rounding of floating-point computations; if this code is evaluated at run time, the default run-time rounding of "round to nearest" is still in effect and takes precedence over the compile-time rounding mode specified by gen(roundConstFp).



Incremental C++ Build
C Compilation
Configuration Files


Set Build Options
Build


Code Generation Options
Code Generation Options