MCPcopy Create free account
hub / github.com/boostorg/json / within_1ulp

Method within_1ulp

test/stream_parser.cpp:612–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610 };
611
612 bool
613 within_1ulp(double x, double y)
614 {
615 std::uint64_t bx, by;
616 std::memcpy(&bx, &x, sizeof(x));
617 std::memcpy(&by, &y, sizeof(y));
618
619 auto diff = bx - by;
620 switch (diff)
621 {
622 case 0:
623 case 1:
624 case 0xffffffffffffffff:
625 return true;
626 default:
627 break;
628 }
629 return false;
630 }
631
632 // Verify that f converts to the
633 // same double produced by `strtod`.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected