ReadFloat32Bytes tries to read a float32 from 'b' and return the value and the remaining bytes. Possible errors: - [ErrShortBytes] (too few bytes) - [TypeError] (not a float32)
(b []byte)
| 366 | // - [ErrShortBytes] (too few bytes) |
| 367 | // - [TypeError] (not a float32) |
| 368 | func ReadFloat32Bytes(b []byte) (f float32, o []byte, err error) { |
| 369 | if len(b) < 5 { |
| 370 | err = ErrShortBytes |
| 371 | return |
| 372 | } |
| 373 | |
| 374 | if b[0] != mfloat32 { |
| 375 | err = TypeError{Method: Float32Type, Encoded: getType(b[0])} |
| 376 | return |
| 377 | } |
| 378 | |
| 379 | f = math.Float32frombits(getMuint32(b)) |
| 380 | o = b[5:] |
| 381 | return |
| 382 | } |
| 383 | |
| 384 | // ReadBoolBytes tries to read a bool |
| 385 | // from 'b' and return the value and the remaining bytes. |
searching dependent graphs…