Module:number base: Difference between revisions
Jump to navigation
Jump to search
Created page with "local export = {} local floor, insert = math.floor, table.insert function export.base12(n) n = floor(tonumber(n)) local digits = "0123456789¹²" local t = {} local sign = "" repeat local d = (n % 12) + 1 n = floor(n / 12) insert(t, 1, digits:sub(d,d)) until n == 0 return sign .. table.concat(t,"") end return export" |
m Sware moved page Module:Base not 10 to Module:number base without leaving a redirect |
||
(No difference)
| |||
Revision as of 23:05, 29 June 2023
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local floor, insert = math.floor, table.insert
function export.base12(n)
n = floor(tonumber(n))
local digits = "0123456789¹²"
local t = {}
local sign = ""
repeat
local d = (n % 12) + 1
n = floor(n / 12)
insert(t, 1, digits:sub(d,d))
until n == 0
return sign .. table.concat(t,"")
end
return export