diff options
author | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
commit | f74161ca4e7eb3c5af9afcbe92522ae3b58987c1 (patch) | |
tree | 3c30a13df5ac7968195c85070a2b074578e669d2 /Master/texmf-dist/tex/context/base/mkiv/l-number.lua | |
parent | 1d5a55ac8f5506a7ae9cfca52f4b588182e199d4 (diff) |
context beta/cont-tmf.zip (Apr 16 12:55)
git-svn-id: svn://tug.org/texlive/trunk@43931 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/l-number.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/l-number.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-number.lua b/Master/texmf-dist/tex/context/base/mkiv/l-number.lua index 001ca31f773..c6f1e33597b 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/l-number.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/l-number.lua @@ -13,6 +13,7 @@ local tostring, tonumber = tostring, tonumber local format, floor, match, rep = string.format, math.floor, string.match, string.rep local concat, insert = table.concat, table.insert local lpegmatch = lpeg.match +local floor = math.floor number = number or { } local number = number @@ -205,3 +206,25 @@ end function number.bits(n) return { bits(n,1) } end + +function number.bytetodecimal(b) + local d = floor(b * 100 / 255 + 0.5) + if d > 100 then + return 100 + elseif d < -100 then + return -100 + else + return d + end +end + +function number.decimaltobyte(d) + local b = floor(d * 255 / 100 + 0.5) + if b > 255 then + return 255 + elseif b < -255 then + return -255 + else + return b + end +end |