summaryrefslogtreecommitdiff
path: root/scripts/context/stubs
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-04-20 17:40:12 +0300
committerMarius <mariausol@gmail.com>2011-04-20 17:40:12 +0300
commit48aee08be6614bf30710ae7c42248f64d55f8f22 (patch)
tree64ff396c95e3079262b2996acc6d3d0025798ed5 /scripts/context/stubs
parent9a911f4fe29fcd7b02102d54ba0e938b40635e59 (diff)
downloadcontext-48aee08be6614bf30710ae7c42248f64d55f8f22.tar.gz
beta 2011.04.20 16:23
Diffstat (limited to 'scripts/context/stubs')
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua20
-rw-r--r--scripts/context/stubs/unix/mtxrun20
2 files changed, 28 insertions, 12 deletions
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 100644
--- 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