Skip to content

Commit 6c420ac

Browse files
committed
Fix B#21
1 parent 31e286a commit 6c420ac

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

vstruct/io/i.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ function i.unpackbits(bit, width)
2424
end
2525

2626
function i.pack(_, data, width)
27+
data = math.trunc(data)
28+
2729
if data < 0 then
2830
data = data + 2^(width*8)
2931
end

vstruct/io/u.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ end
3232
function u.pack(_, data, width)
3333
local s = ""
3434
local e = io("endianness", "get")
35+
data = math.trunc(data)
3536

3637
for i=1,width do
3738
if e == "big" then

0 commit comments

Comments
 (0)