MCPcopy Create free account
hub / github.com/apache/arrow / UlpDistance

Method UlpDistance

cpp/src/arrow/testing/math.cc:61–70  ·  view source on GitHub ↗

This implementation is inspired by: https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Source from the content-addressed store, hash-verified

59 // This implementation is inspired by:
60 // https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
61 static UIntType UlpDistance(Float left, Float right) {
62 auto unsigned_left = util::SafeCopy<UIntType>(left);
63 auto unsigned_right = util::SafeCopy<UIntType>(right);
64 auto biased_left = ConvertSignAndMagnitudeToBiased(unsigned_left);
65 auto biased_right = ConvertSignAndMagnitudeToBiased(unsigned_right);
66 if (biased_left > biased_right) {
67 std::swap(biased_left, biased_right);
68 }
69 return biased_right - biased_left;
70 }
71
72 private:
73 // Source reference (GoogleTest):

Callers

nothing calls this directly

Calls 1

swapFunction · 0.85

Tested by

no test coverage detected