From 0f46871b4cc45f2c3bd5bdb0aa0f7615795a2c6d Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Fri, 23 Oct 2020 11:40:18 +0200 Subject: Fix encoding for float64 and generate conversion for Timestamp - fixes encoding/decoding of float64 - uses little endian (contrary to all other types) - generates helper methods for vpe_types.Timestamp type - adds usage code to simple-client and binapi-types examples Change-Id: I2e83eee0629eb67964049406c50c7ee0a692ccaf Signed-off-by: Ondrej Fabry --- codec/codec.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'codec/codec.go') diff --git a/codec/codec.go b/codec/codec.go index 3ae578b..21354a1 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -156,12 +156,12 @@ func (b *Buffer) DecodeInt64() int64 { } func (b *Buffer) EncodeFloat64(v float64) { - binary.BigEndian.PutUint64(b.buf[b.pos:b.pos+8], math.Float64bits(v)) + binary.LittleEndian.PutUint64(b.buf[b.pos:b.pos+8], math.Float64bits(v)) b.pos += 8 } func (b *Buffer) DecodeFloat64() float64 { - v := math.Float64frombits(binary.BigEndian.Uint64(b.buf[b.pos : b.pos+8])) + v := math.Float64frombits(binary.LittleEndian.Uint64(b.buf[b.pos : b.pos+8])) b.pos += 8 return v } -- cgit 1.2.3-korg