MCPcopy Index your code
hub / github.com/vmihailenco/msgpack / EncodeFloat64

Method EncodeFloat64

encode_number.go:154–165  ·  view source on GitHub ↗
(n float64)

Source from the content-addressed store, hash-verified

152}
153
154func (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
167func (e *Encoder) write1(code byte, n uint8) error {
168 e.buf = e.buf[:2]

Callers 2

EncodeMethod · 0.95
encodeFloat64ValueFunction · 0.80

Calls 2

EncodeIntMethod · 0.95
write8Method · 0.95

Tested by

no test coverage detected