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

Function adjustFloatingPoint

fdbclient/Tuple.cpp:53–62  ·  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

51// If decoding and the sign bit is 0 (the number is negative), flip all the bits.
52// Otherwise, the number is positive, so flip the sign bit.
53static void adjustFloatingPoint(uint8_t* bytes, size_t size, bool encode) {
54 if ((encode && ((uint8_t)(bytes[0] & 0x80) != (uint8_t)0x00)) ||
55 (!encode && ((uint8_t)(bytes[0] & 0x80) != (uint8_t)0x80))) {
56 for (size_t i = 0; i < size; i++) {
57 bytes[i] ^= (uint8_t)0xff;
58 }
59 } else {
60 bytes[0] ^= (uint8_t)0x80;
61 }
62}
63
64Tuple::Tuple(StringRef const& str, bool exclude_incomplete, bool include_user_type) {
65 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