#pragma STDC cx_limited_range

Descripton

The STDC cx_limited_range pragma instructs the compiler that within the scope it controls, complex division and absolute value are only invoked with values such that intermediate calculation will not overflow or lose significance. The default setting of the pragma is off.

Syntax

Read syntax diagramSkip visual syntax diagram                                     .-off-----.
>>-#--pragma--STDC cx_limited_range--+-on------+---------------><
                                     '-default-'

Notes

Using values outside the limited range may generate wrong results, where limited range is defined such that the "obvious symbolic definition" will not overflow or run out of precision.

The pragma can be placed outside external declarations or before all explicit declarations and statements inside a compound statement. When it occurs outside external declarations, the pragma is effective from its occurrence until another CX_LIMITED_RANGE pragma is encountered, or until the end of the translation unit. When it is inside a compound statement, the pragma is effective from its occurrence until another CX_LIMITED_RANGE pragma is encountered (including within a nested compound statement), or until the end of the compound statement; at the end of a compound statement the state for the pragma is restored to its condition just before the compound statement. If this pragma is used in any other context, the behavior is undefined.

Examples

Example 1:

#include <complex.h> 

_Complex double a, b, c, d; 
void p() {

d = b/c; 

{

#pragma STDC CX_LIMITED_RANGE ON 

a = b / c; 

}
}

Example 2:

#include <complex.h> 

_Complex double cd = 10.10 + 10.10*I; 
int p() { 

#pragma STDC CX_LIMITED_RANGE ON  

double d = cabs(cd);  
}