tape: Add float functions to the encoder
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package tape
|
||||
|
||||
import "io"
|
||||
import "math"
|
||||
|
||||
// Encodable is any type that can write itself to an encoder.
|
||||
type Encodable interface {
|
||||
@@ -118,3 +119,13 @@ func (this *Encoder) EncodeGBEU(value uint64) (n int, err error) {
|
||||
|
||||
return this.Write(buffer[:])
|
||||
}
|
||||
|
||||
// WriteFloat32 encodes a 32-bit floating point value to the output writer.
|
||||
func (this *Encoder) WriteFloat32(value float32) (n int, err error) {
|
||||
return this.WriteUint32(math.Float32bits(value))
|
||||
}
|
||||
|
||||
// WriteFloat64 encodes a 64-bit floating point value to the output writer.
|
||||
func (this *Encoder) WriteFloat64(value float64) (n int, err error) {
|
||||
return this.WriteUint64(math.Float64bits(value))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user