summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2011-04-20 16:23:00 +0200
committerHans Hagen <pragma@wxs.nl>2011-04-20 16:23:00 +0200
commit1957d157cef3b1f7e37740c831daa7994791129a (patch)
tree800bd8de707f7e50a0a95da9c6e116c06b83945f /scripts
parent2a7dc895b9ca40a38cc4bdb36be94f59bdbe5e4f (diff)
downloadcontext-1957d157cef3b1f7e37740c831daa7994791129a.tar.gz
beta 2011.04.20 16:23
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtxrun.lua20
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua20
-rwxr-xr-xscripts/context/stubs/unix/mtxrun20
3 files changed, 42 insertions, 18 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index a72c56251..2f81b4629 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -1899,16 +1899,24 @@ function number.clearbit(x, p)
return hasbit(x, p) and x - p or x
end
+
function number.tobitstring(n)
if n == 0 then
- return "0"
+ return "00000000"
else
- local t = { }
+ tc = 0
+ t = {}
while n > 0 do
- insert(t,1,n % 2 > 0 and 1 or 0)
- n = floor(n/2)
- end
- return concat(t)
+ table.insert(t,1,n % 2 > 0 and 1 or 0)
+ n = math.floor(n/2)
+ tc = tc + 1
+ end
+ while tc % 8 > 0 do
+ table.insert(t,1,0)
+ tc = tc + 1
+ end
+ n = table.concat(t)
+ return n
end
end
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index a72c56251..2f81b4629 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -1899,16 +1899,24 @@ function number.clearbit(x, p)
return hasbit(x, p) and x - p or x
end
+
function number.tobitstring(n)
if n == 0 then
- return "0"
+ return "00000000"
else
- local t = { }
+ tc = 0
+ t = {}
while n > 0 do
- insert(t,1,n % 2 > 0 and 1 or 0)
- n = floor(n/2)
- end
- return concat(t)
+ table.insert(t,1,n % 2 > 0 and 1 or 0)
+ n = math.floor(n/2)
+ tc = tc + 1
+ end
+ while tc % 8 > 0 do
+ table.insert(t,1,0)
+ tc = tc + 1
+ end
+ n = table.concat(t)
+ return n
end
end
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index a72c56251..2f81b4629 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -1899,16 +1899,24 @@ function number.clearbit(x, p)
return hasbit(x, p) and x - p or x
end
+
function number.tobitstring(n)
if n == 0 then
- return "0"
+ return "00000000"
else
- local t = { }
+ tc = 0
+ t = {}
while n > 0 do
- insert(t,1,n % 2 > 0 and 1 or 0)
- n = floor(n/2)
- end
- return concat(t)
+ table.insert(t,1,n % 2 > 0 and 1 or 0)
+ n = math.floor(n/2)
+ tc = tc + 1
+ end
+ while tc % 8 > 0 do
+ table.insert(t,1,0)
+ tc = tc + 1
+ end
+ n = table.concat(t)
+ return n
end
end