Menu

#8 Fix helpers::isinf for 32 bit

open
nobody
None
5
2013-06-09
2013-06-09
No

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);
}

Discussion


Log in to post a comment.