aboutsummaryrefslogtreecommitdiffstats
path: root/codec
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2020-10-23 11:40:18 +0200
committerOndrej Fabry <ofabry@cisco.com>2020-10-30 10:00:00 +0000
commit0f46871b4cc45f2c3bd5bdb0aa0f7615795a2c6d (patch)
tree3d3de8febc3e2becfbbbd648538fc5dd1748374f /codec
parentcb540dc166c12180adba024d5b8fd463d2582928 (diff)
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 <ofabry@cisco.com>
Diffstat (limited to 'codec')
-rw-r--r--codec/codec.go4
1 files changed, 2 insertions, 2 deletions
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
}