aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-06-16 11:00:16 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-06-16 11:00:16 +0200
commitcad0eac50b70a280611dd89440a805912ebfad8b (patch)
treeef1946cd0da4e3c4acfd5f0032ddae6f36c5d76b /src
parent1f501616500ee308da6b88e2ecef4bf19490d1ee (diff)
downloadfengari-cad0eac50b70a280611dd89440a805912ebfad8b.tar.gz
fengari-cad0eac50b70a280611dd89440a805912ebfad8b.tar.bz2
fengari-cad0eac50b70a280611dd89440a805912ebfad8b.zip
packnum: num can be 32 bits
Diffstat (limited to 'src')
-rw-r--r--src/lstrlib.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index f2518e0..9344794 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -548,9 +548,10 @@ const packint = function(b, n, islittle, size, neg) {
const packnum = function(b, n, islittle, size) {
let dv = new DataView(new ArrayBuffer(size));
- dv.setFloat64(0, n, islittle);
+ if (size === 4) dv.setFloat32(0, n, islittle);
+ else dv.setFloat64(0, n, islittle);
- for (let i = 0; i < 8; i++)
+ for (let i = 0; i < size; i++)
b.push(dv.getUint8(i, islittle));
};