Skip to content

Commit

Permalink
Add lo/hi properties to i64/u64 types to help use with bit32 library
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Mar 19, 2024
1 parent 38e05a3 commit 8ab3fd2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions flow/pua/peerdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 8ab3fd2

Please sign in to comment.