Isnan is retained when you assign the FP type to a different size.

Basically:

float  nanf=std::numeric_limits::signaling_NaN<decltype(g_nanf)>();
double nand = nanf;
assert(std::isnan(nand));

can argue fire? also if i assigned double nan to swim

+4
source share
3 answers

From N3337:

4.6 Floating Point Promotion [conv.fpprom]

1 Type value floatcan be converted to prvalue type double. The value does not change.

4.8 Floating point conversions [conv.double]

1 prvalue . , , . , . , undefined.

3.9.1 [basic.fundamental]

8 : float, double long double. double , , float, long double , double. float - double; double long double.

, NaN . isnan C. N1570:

7.12.3.4 isnan

2 isnan , NaN.

, : , float double NaN-ness. double float, , , double NaN, , " ".

(, "" , .)

+3

++ IEEE-754; , , 6.2 NaNs:

NaN, , , NaN...

NaNs:

, , NaN.

NaN , (. 7.2) -...

+1

BoBTFish . , , :

, :

  • NaN NaN.
  • / single double, , .

, NaN float/double.

0

Source: https://habr.com/ru/post/1528780/


All Articles