MCPcopy Create free account
hub / github.com/apache/tvm-ffi / FastMathSafeIsInf

Function FastMathSafeIsInf

tests/cpp/extra/test_json_parser.cc:47–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47inline bool FastMathSafeIsInf(double x) {
48#ifdef __FAST_MATH__
49 // IEEE 754 standard: https://en.wikipedia.org/wiki/IEEE_754
50 // Inf is encoded as all 1s in the exponent and zero in the mantissa
51 static_assert(sizeof(double) == sizeof(uint64_t), "Unexpected double size");
52 uint64_t bits = *reinterpret_cast<const uint64_t*>(&x);
53 uint64_t exponent = (bits >> 52) & 0x7FF;
54 uint64_t mantissa = bits & 0xFFFFFFFFFFFFFull;
55 // inf is encoded as all 1s in the exponent and zero in the mantissa
56 return (exponent == 0x7FF) && (mantissa == 0);
57#else
58 return std::isinf(x);
59#endif
60}
61
62TEST(JSONParser, BoolNull) {
63 // boolean value

Callers 2

WriteFloatMethod · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected