Float64 writes a float64.
(val float64)
| 118 | |
| 119 | // Float64 writes a float64. |
| 120 | func (writer *Writer) Float64(val float64) { |
| 121 | // Float encoding produces byte-comparable serialized values when looking at the exponent and mantissa. This means |
| 122 | // that we just have to flip to exponent and mantissa for negative values, and flip the sign bit so that negatives |
| 123 | // sort before positives. To do this, we take advantage of arithmetic shifting by casting to a signed integer to |
| 124 | // create a mask that only exists for negative values. |
| 125 | uval := math.Float64bits(val) |
| 126 | uval ^= uint64(int64(uval)>>63) & 0x7FFFFFFFFFFFFFFF |
| 127 | uval ^= 0x8000000000000000 |
| 128 | writer.Uint64(uval) |
| 129 | } |
| 130 | |
| 131 | // VariableInt writes an int64 using variable-length encoding. Smaller values use less space at the cost of larger |
| 132 | // values using more bytes, but this is generally more space-efficient. This does carry a small computational hit when |