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.
| 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. |
| 78 | static 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 | |
| 89 | Tuple::Tuple(StringRef const& str) { |
| 90 | data.append(data.arena(), str.begin(), str.size()); |