2021-12-30 01:12:36 +03:00
|
|
|
package decoders
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/wader/fq/pkg/decode"
|
2022-01-14 08:32:19 +03:00
|
|
|
"github.com/wader/fq/pkg/scalar"
|
2021-12-30 01:12:36 +03:00
|
|
|
)
|
|
|
|
|
2022-01-20 08:53:33 +03:00
|
|
|
func decodeFloatFn(sms ...scalar.Mapper) (DecodeFn, error) {
|
2022-01-14 08:32:19 +03:00
|
|
|
// A float is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to Java's
|
|
|
|
// floatToIntBits and then encoded in little-endian format.
|
2022-05-20 16:10:41 +03:00
|
|
|
return func(name string, d *decode.D) any {
|
2022-01-20 08:53:33 +03:00
|
|
|
return d.FieldF32(name, sms...)
|
2021-12-30 01:12:36 +03:00
|
|
|
}, nil
|
|
|
|
}
|