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

Method ReadFloat64

msgp/read.go:587–611  ·  view source on GitHub ↗

ReadFloat64 reads a float64 from the reader. (If the value on the wire is encoded as a float32, it will be up-cast to a float64.)

()

Source from the content-addressed store, hash-verified

585// (If the value on the wire is encoded as a float32,
586// it will be up-cast to a float64.)
587func (m *Reader) ReadFloat64() (f float64, err error) {
588 var p []byte
589 p, err = m.R.Peek(9)
590 if err != nil {
591 // we'll allow a conversion from float32 to float64,
592 // since we don't lose any precision
593 if err == io.EOF && len(p) > 0 && p[0] == mfloat32 {
594 ef, err := m.ReadFloat32()
595 return float64(ef), err
596 }
597 return
598 }
599 if p[0] != mfloat64 {
600 // see above
601 if p[0] == mfloat32 {
602 ef, err := m.ReadFloat32()
603 return float64(ef), err
604 }
605 err = badPrefix(Float64Type, p[0])
606 return
607 }
608 f = math.Float64frombits(getMuint64(p))
609 _, err = m.R.Skip(9)
610 return
611}
612
613// ReadFloat32 reads a float32 from the reader
614func (m *Reader) ReadFloat32() (f float32, err error) {

Callers 9

TestReadFloat64Function · 0.95
BenchmarkReadFloat64Function · 0.95
FuzzReaderFunction · 0.95
ReadJSONNumberMethod · 0.95
ReadIntfMethod · 0.95
DecodeMsgMethod · 0.80
rwFloat64Function · 0.80
DecodeMsgMethod · 0.80
DecodeMsgMethod · 0.80

Calls 4

ReadFloat32Method · 0.95
badPrefixFunction · 0.85
getMuint64Function · 0.85
SkipMethod · 0.80

Tested by 3

TestReadFloat64Function · 0.76
BenchmarkReadFloat64Function · 0.76
FuzzReaderFunction · 0.76