summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/l-number.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2019-02-22 20:29:46 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2019-02-22 20:29:46 +0100
commit7b271baae19db1528fbe6621bdf50af89a5a336b (patch)
tree4fc24a8f2be20aa90e90f6e1bcb62d69f4946235 /tex/context/base/mkiv/l-number.lua
parent67b9965fe473d18f13ed4c40f1e4e008eb870322 (diff)
downloadcontext-7b271baae19db1528fbe6621bdf50af89a5a336b.tar.gz
2019-02-22 19:43:00
Diffstat (limited to 'tex/context/base/mkiv/l-number.lua')
-rw-r--r--tex/context/base/mkiv/l-number.lua23
1 files changed, 15 insertions, 8 deletions
diff --git a/tex/context/base/mkiv/l-number.lua b/tex/context/base/mkiv/l-number.lua
index a83e8f8f9..9fd2f82f7 100644
--- a/tex/context/base/mkiv/l-number.lua
+++ b/tex/context/base/mkiv/l-number.lua
@@ -81,13 +81,14 @@ if bit32 then
"0", "0", "0", "0", "0", "0", "0", "0",
}
- function number.tobitstring(b,m)
- -- if really needed we can speed this one up
- -- because small numbers need less extraction
- local n = 32
- for i=0,31 do
+ function number.tobitstring(b,m,w)
+ if not w then
+ w = 32
+ end
+ local n = w
+ for i=0,w-1 do
local v = bextract(b,i)
- local k = 32 - i
+ local k = w - i
if v == 1 then
n = k
t[k] = "1"
@@ -95,12 +96,14 @@ if bit32 then
t[k] = "0"
end
end
- if m then
+ if w then
+ return concat(t,"",1,w)
+ elseif m then
m = 33 - m * 8
if m < 1 then
m = 1
end
- return concat(t,"",m)
+ return concat(t,"",1,m)
elseif n < 8 then
return concat(t)
elseif n < 16 then
@@ -232,3 +235,7 @@ function number.decimaltobyte(d)
return b
end
end
+
+function number.idiv(i,d)
+ return floor(i/d) -- i//d in 5.3
+end