ReadFloat64Bytes tries to read a float64 from 'b' and return the value and the remaining bytes. Possible errors: - [ErrShortBytes] (too few bytes) - [TypeError] (not a float64)
(b []byte)
| 331 | // - [ErrShortBytes] (too few bytes) |
| 332 | // - [TypeError] (not a float64) |
| 333 | func ReadFloat64Bytes(b []byte) (f float64, o []byte, err error) { |
| 334 | if len(b) < 9 { |
| 335 | if len(b) >= 5 && b[0] == mfloat32 { |
| 336 | var tf float32 |
| 337 | tf, o, err = ReadFloat32Bytes(b) |
| 338 | f = float64(tf) |
| 339 | return |
| 340 | } |
| 341 | err = ErrShortBytes |
| 342 | return |
| 343 | } |
| 344 | |
| 345 | if b[0] != mfloat64 { |
| 346 | if b[0] == mfloat32 { |
| 347 | var tf float32 |
| 348 | tf, o, err = ReadFloat32Bytes(b) |
| 349 | f = float64(tf) |
| 350 | return |
| 351 | } |
| 352 | err = badPrefix(Float64Type, b[0]) |
| 353 | return |
| 354 | } |
| 355 | |
| 356 | f = math.Float64frombits(getMuint64(b)) |
| 357 | o = b[9:] |
| 358 | return |
| 359 | } |
| 360 | |
| 361 | // ReadFloat32Bytes tries to read a float32 |
| 362 | // from 'b' and return the value and the remaining bytes. |
searching dependent graphs…