#pragma STDC cx_limited_range

Category

Optimization and tuning

Purpose

Instructs the compiler that complex division and absolute value are only invoked with values such that intermediate calculation will not overflow or lose significance.

Syntax

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

Usage

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

The pragma is effective from its first occurrence until another cx_limited_range pragma is encountered, or until the end of the translation unit. When the pragma occurs inside a compound statement (including within a nested compound statement), it is effective from its first occurrence until another cx_limited_range pragma is encountered, or until the end of the compound statement.

Examples

The following example shows the use of the pragma for complex division:

#include <complex.h> 

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

d = b/c; 

{

#pragma STDC CX_LIMITED_RANGE ON 

a = b / c; 

}
}

The following example shows the use of the pragma for complex absolute value:

#include <complex.h> 

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

#pragma STDC CX_LIMITED_RANGE ON  

double d = cabs(cd);  
}

Related information