* Append the given double as big-endian IEEE 754 binary64 */
| 111 | * Append the given double as big-endian IEEE 754 binary64 |
| 112 | */ |
| 113 | static inline void PackFloat64BE(double f, std::string& builder) |
| 114 | { |
| 115 | Double2BytesConverter converter; |
| 116 | |
| 117 | converter.f = f; |
| 118 | |
| 119 | if (MACHINE_LITTLE_ENDIAN) { |
| 120 | SwapBytes(converter.buf[0], converter.buf[7]); |
| 121 | SwapBytes(converter.buf[1], converter.buf[6]); |
| 122 | SwapBytes(converter.buf[2], converter.buf[5]); |
| 123 | SwapBytes(converter.buf[3], converter.buf[4]); |
| 124 | } |
| 125 | |
| 126 | builder.append((char*)converter.buf, 8); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Append the given string's length (BE uint64) and the string itself |