(n float64)
| 152 | } |
| 153 | |
| 154 | func (e *Encoder) EncodeFloat64(n float64) error { |
| 155 | if e.flags&useCompactFloatsFlag != 0 { |
| 156 | // Both NaN and Inf convert to int64(-0x8000000000000000) |
| 157 | // If n is NaN then it never compares true with any other value |
| 158 | // If n is Inf then it doesn't convert from int64 back to +/-Inf |
| 159 | // In both cases the comparison works. |
| 160 | if float64(int64(n)) == n { |
| 161 | return e.EncodeInt(int64(n)) |
| 162 | } |
| 163 | } |
| 164 | return e.write8(msgpcode.Double, math.Float64bits(n)) |
| 165 | } |
| 166 | |
| 167 | func (e *Encoder) write1(code byte, n uint8) error { |
| 168 | e.buf = e.buf[:2] |
no test coverage detected