| 264 | void Encoder::writeUInt(uint64_t i) {writeInt(i, (i < 2048), true);} |
| 265 | |
| 266 | void Encoder::writeDouble(double n) { |
| 267 | throwIf(std::isnan(n), InvalidData, "Can't write NaN"); |
| 268 | #if 0 // Perhaps an option in the future? |
| 269 | if (isIntRepresentable(n)) { |
| 270 | return writeInt((int64_t)n); |
| 271 | } else |
| 272 | #endif |
| 273 | if (isFloatRepresentable(n)) { |
| 274 | return _writeFloat((float)n); |
| 275 | } else { |
| 276 | endian::littleEndianDouble swapped = n; |
| 277 | auto buf = placeValue<false>(kFloatTag, 0x08, 2 + sizeof(swapped)); |
| 278 | buf[1] = 0; |
| 279 | memcpy(&buf[2], &swapped, sizeof(swapped)); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | void Encoder::writeFloat(float n) { |
| 284 | throwIf(std::isnan(n), InvalidData, "Can't write NaN"); |
nothing calls this directly
no outgoing calls
no test coverage detected