MCPcopy
hub / github.com/tinylib/msgp / WriteFloat

Method WriteFloat

msgp/write.go:355–361  ·  view source on GitHub ↗

WriteFloat writes a float to the writer as either float64 or float32 when it represents the exact same value

(f float64)

Source from the content-addressed store, hash-verified

353// WriteFloat writes a float to the writer as either float64
354// or float32 when it represents the exact same value
355func (mw *Writer) WriteFloat(f float64) error {
356 f32 := float32(f)
357 if float64(f32) == f {
358 return mw.prefix32(mfloat32, math.Float32bits(f32))
359 }
360 return mw.prefix64(mfloat64, math.Float64bits(f))
361}
362
363// WriteFloat64 writes a float64 to the writer
364func (mw *Writer) WriteFloat64(f float64) error {

Callers 4

WriteJSONNumberMethod · 0.95
TestAppendFloatFunction · 0.95
EncodeMsgMethod · 0.80
EncodeMsgMethod · 0.80

Calls 2

prefix32Method · 0.95
prefix64Method · 0.95

Tested by 1

TestAppendFloatFunction · 0.76