| 30 | #include <utility> |
| 31 | |
| 32 | inline uint64_t EncodeDoubleToUInt64(double value) { |
| 33 | uint64_t result = 0; |
| 34 | |
| 35 | __builtin_memcpy(&result, &value, sizeof(value)); |
| 36 | |
| 37 | if ((result >> 63) == 1) { |
| 38 | // signed bit would be zero |
| 39 | result ^= 0xffffffffffffffff; |
| 40 | } else { |
| 41 | // signed bit would be one |
| 42 | result |= 0x8000000000000000; |
| 43 | } |
| 44 | |
| 45 | return result; |
| 46 | } |
| 47 | |
| 48 | inline double DecodeDoubleFromUInt64(uint64_t value) { |
| 49 | if ((value >> 63) == 0) { |
no outgoing calls
no test coverage detected