The following works only for 64 bits:
inline bool isposinf(double value) {
long& bits = *((long *)&value);
return bits == 0x7FF0000000000000;
}
inline bool isneginf(double value) {
long& bits = *((long *)&value);
return bits == 0xFFF0000000000000;
}
inline bool isinf(double value) {
// works only in x64
int* a1 = (int*)0xFFF0000000000000;
int* a2 = (int*)0x7FF0000000000000;
int* bits = *((int**)&value);
return (bits == a1) || (bits == a2);
}