From 8ab3fd203efed305fc5ef037df76c677803fa621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Tue, 19 Mar 2024 14:33:31 +0000 Subject: [PATCH] Add lo/hi properties to i64/u64 types to help use with bit32 library --- flow/pua/peerdb.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/flow/pua/peerdb.go b/flow/pua/peerdb.go index 9f72df00ec..a2e8e906cc 100644 --- a/flow/pua/peerdb.go +++ b/flow/pua/peerdb.go @@ -467,6 +467,10 @@ func LuaI64Index(ls *lua.LState) int { ls.Push(LuaU64.New(ls, uint64(i64))) case "float64": ls.Push(lua.LNumber(i64)) + case "hi": + ls.Push(lua.LNumber(i64 >> 32)) + case "lo": + ls.Push(lua.LNumber(uint32(i64))) default: return 0 } @@ -483,6 +487,10 @@ func LuaU64Index(ls *lua.LState) int { ls.Push(u64ud) case "float64": ls.Push(lua.LNumber(u64)) + case "hi": + ls.Push(lua.LNumber(u64 >> 32)) + case "lo": + ls.Push(lua.LNumber(uint32(u64))) default: return 0 } @@ -590,8 +598,7 @@ func LuaDecimalIndex(ls *lua.LState) int { case "int64": ls.Push(LuaI64.New(ls, num.IntPart())) case "float64": - f64, _ := num.Float64() - ls.Push(lua.LNumber(f64)) + ls.Push(lua.LNumber(num.InexactFloat64())) default: return 0 }