MCPcopy Create free account
hub / github.com/oschwald/maxminddb-golang / decodeFloat64

Method decodeFloat64

internal/decoder/data_decoder.go:193–207  ·  view source on GitHub ↗

DecodeFloat64 decodes a 64-bit float from the given offset.

(size, offset uint)

Source from the content-addressed store, hash-verified

191
192// DecodeFloat64 decodes a 64-bit float from the given offset.
193func (d *DataDecoder) decodeFloat64(size, offset uint) (float64, uint, error) {
194 if size != 8 {
195 return 0, 0, mmdberrors.NewInvalidDatabaseError(
196 "the MaxMind DB file's data section contains bad data (float 64 size of %v)",
197 size,
198 )
199 }
200 if offset+size > uint(len(d.buffer)) {
201 return 0, 0, mmdberrors.NewOffsetError()
202 }
203
204 newOffset := offset + size
205 bits := binary.BigEndian.Uint64(d.buffer[offset:newOffset])
206 return math.Float64frombits(bits), newOffset, nil
207}
208
209// DecodeFloat32 decodes a 32-bit float from the given offset.
210func (d *DataDecoder) decodeFloat32(size, offset uint) (float32, uint, error) {

Callers 3

ReadFloat64Method · 0.80
unmarshalFloat64Method · 0.80
tryFastDecodeTypedMethod · 0.80

Calls 2

NewInvalidDatabaseErrorFunction · 0.92
NewOffsetErrorFunction · 0.92

Tested by

no test coverage detected