DecodeFloat64 decodes a 64-bit float from the given offset.
(size, offset uint)
| 191 | |
| 192 | // DecodeFloat64 decodes a 64-bit float from the given offset. |
| 193 | func (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. |
| 210 | func (d *DataDecoder) decodeFloat32(size, offset uint) (float32, uint, error) { |
no test coverage detected