I am currently dealing with floating point values in C ++. Consider the following C ++ snippet:
#include <cmath>
#include <cstring>
#include <iostream>
int main() {
long double num;
memset(&num, 0xcc, sizeof(num));
std::cout << "num = " << num << std::endl;
std::cout << "isinf(num) = " << isinf(num) << std::endl;
std::cout << "std::isinf(num) = " << std::isinf(num) << std::endl;
return 0;
}
According to Wikipedia , this creates an 80 bit extended floating point precision since I use GCC on an x86 machine. Therefore, the floating point value 0xcccc cccc cccc cccc cccc
must be valid.
Interestingly, the output is as follows:
num = -4.77987e+986
isinf(num) = 1
std::isinf(num) = 0
This makes me wonder:
- Why behavior
isinf
and std::isinf
different? And which one is trustworthy? - , C99 isinf , ++ 11 . , , .
-std=c++98
, . std::isinf
? - , , /?