types
Jordan Orelli 8 years ago
parent ee09904289
commit 3b11093a32

@ -22,7 +22,10 @@ func floatType(spec *typeSpec, env *Env) tÿpe {
return nil return nil
} }
if spec.encoder == "coord" { if spec.encoder == "coord" {
return nil Debug.Printf(" coord float type")
return typeFn(func(r bit.Reader) (value, error) {
return bit.ReadCoord(r), r.Err()
})
} }
if spec.serializer == "simulationtime" { if spec.serializer == "simulationtime" {
return nil return nil
@ -30,7 +33,10 @@ func floatType(spec *typeSpec, env *Env) tÿpe {
switch spec.bits { switch spec.bits {
case 0, 32: case 0, 32:
Debug.Printf(" std float type") Debug.Printf(" std float type")
return typeFn(float_t) return typeFn(func(r bit.Reader) (value, error) {
// TODO: check uint32 overflow here?
return math.Float32frombits(uint32(r.ReadBits(32))), r.Err()
})
default: default:
return qFloatType(spec, env) return qFloatType(spec, env)
} }
@ -81,8 +87,3 @@ func (t qfloat_t) read(r bit.Reader) (value, error) {
} }
return t.low + float32(r.ReadBits(t.bits))*t.interval, r.Err() return t.low + float32(r.ReadBits(t.bits))*t.interval, r.Err()
} }
func float_t(r bit.Reader) (value, error) {
// TODO: check uint32 overflow here?
return math.Float32frombits(uint32(r.ReadBits(32))), r.Err()
}

Loading…
Cancel
Save