MCPcopy Create free account
hub / github.com/apple/foundationdb / adjust_floating_point

Function adjust_floating_point

bindings/flow/Tuple.cpp:78–87  ·  view source on GitHub ↗

If encoding and the sign bit is 1 (the number is negative), flip all the bits. If decoding and the sign bit is 0 (the number is negative), flip all the bits. Otherwise, the number is positive, so flip the sign bit.

Source from the content-addressed store, hash-verified

76// If decoding and the sign bit is 0 (the number is negative), flip all the bits.
77// Otherwise, the number is positive, so flip the sign bit.
78static void adjust_floating_point(uint8_t* bytes, size_t size, bool encode) {
79 if ((encode && ((uint8_t)(bytes[0] & 0x80) != (uint8_t)0x00)) ||
80 (!encode && ((uint8_t)(bytes[0] & 0x80) != (uint8_t)0x80))) {
81 for (size_t i = 0; i < size; i++) {
82 bytes[i] ^= (uint8_t)0xff;
83 }
84 } else {
85 bytes[0] ^= (uint8_t)0x80;
86 }
87}
88
89Tuple::Tuple(StringRef const& str) {
90 data.append(data.arena(), str.begin(), str.size());

Callers 3

Tuple.cppFile · 0.85
getFloatMethod · 0.85
getDoubleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected