baseconvert

Pagbaliwenna dagiti numero iti maysa a nainaganan a batayan ti baetan ti 2 ken 36, tapno mausar kadagiti plantilia kas ti }, }, }, kdpy.

Dokumentasion ti modulo

Kas pagarigan

local BaseConvert = require('Modulo:BaseConvert') BaseConvert.convert({n = 14600926, base = 16}) -- mangited ti 'DECADE' 

Dagiti argumento:

  • n - (nasken) ti numero a pagbaliwen, a kas maysa a kuerdas. Mabalin a daytoy ken maysa a numero, no ti maikabil a batayan ket 10.
  • base - (nasken) ti batayan a nasken a pagbaliwen ti numero. Mabalin a baetan ti 2 ken 36, mainayon.
  • from - ti batayan ti maikabil. Kasisigud iti 10 (wenno 16 no ti maikabil ket adad iti maysa a pangyuna nga '0x'). Palagip a dagiti batayan a sabali ngem 10 ken saan a masuportaran no ti maikabil ket adda iti maysa a pisi ti sangabukel a paset.
  • precision - numero dagiti digit a maipakita kalpasan ti radix a puntos. Dagiti sumursurot a sero ket mainayonto no kasapulan. No saan a nainaganan, nupay kasta adu kadagiti digit masapul ket maipakitanto, aginggana iti 10.
  • width - ti kabassitan a bilang dagiti digiti a maipakita sakbay ti radix a puntos. Dagiti umun-una a sero ket mainayonto no masapul.
  • default - Ti pateg a maited no ti "n" ket awan linaon wenno saan a numeriko. Kasisigud daytoy ti pateg iti "n".
  • prefix / suffix - wikitext a mainayon sakbay/kalpasan ti naisubli a resulta. Saanto a mainayon no ti "n" ket awan linaon wenno saan a numeriko. Kas pagarigan, mabalinmo ti agusar ti prefix iti 0x no pagbaliwen iti hex, wenno ti suffix iti 8 no pagbaliwen iti octal.
local p = {}  local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'  local function normalizeFullWidthChars(s) return mw.ustring.gsub(s, '[!-~]', function(s) return mw.ustring.char(mw.ustring.codepoint(s, 1) - 0xFEE0) end) end  local function _convert(n, base, from, precision, width, default, prefix, suffix) n = tostring(n)  -- strip off any leading '0x' (unless x is a valid digit in the input base) from = tonumber(from) if not from or from < 34 then local c n, c = n:gsub('^(-?)0[Xx]', '%1') if c > 0 and not from then from = 16 end end  -- check for a negative sign. Do this while the input is still in string form, -- because tonumber doesn't support negative numbers in non-10 bases. local sign = '' local c n, c = n:gsub('^-', '') if c > 0 then sign = '-' end  -- replace any full-width Unicode characters in the string with their ASCII equivalents n = normalizeFullWidthChars(n)  -- handle scientific notation with whitespace around the 'e' e.g. '5 e7' n = n:gsub('%s*[eE]%s*', 'e')  from = from or 10 local num = tonumber(n, from) base = tonumber(base) precision = tonumber(precision) width = tonumber(width)  if not num or not base then return default or n end  local i, f = math.modf(num)  local t = {} repeat local d = (i % base) + 1 i = math.floor(i / base) table.insert(t, 1, digits:sub(d, d)) until i == 0 while #t < (width or 0) do table.insert(t, 1, '0') end local intPart = table.concat(t, '')  -- compute the fractional part local tf = {} while f > 0 and #tf < (precision or 10) do f = f * base i, f = math.modf(f) table.insert(tf, digits:sub(i + 1, i + 1)) end  -- add trailing zeros if needed if precision and #tf < precision then for i = 1, precision - #tf do table.insert(tf, '0') end end  local fracPart = table.concat(tf, '')  -- remove trailing zeros if not needed if not precision then fracPart = fracPart:gsub('0*$', '') end  -- add the radix point if needed if #fracPart > 0 then fracPart = '.' .. fracPart end  return (prefix or '') .. sign .. intPart .. fracPart .. (suffix or '') end  function p.convert(frame) -- Allow for invocation via #invoke or directly from another module local args if frame == mw.getCurrentFrame() then args = frame.args else args = frame end  local n = args.n local base = args.base local from = args.from local precision = args.precision local width = args.width local default = args.default local prefix = args.prefix local suffix = args.suffix return _convert(n, base, from, precision, width, default, prefix, suffix) end  setmetatable(p, { __index = function(t, k) local from, base = k:match('^([0-9]+)to([0-9]+)$') if not from then return nil end return function(frame) local args = frame.args return _convert(mw.text.trim(args[1]), base, from, args.precision, args.width, args.default, args.prefix, args.suffix) end end })  return p 

Tags:

🔥 Trending searches on Wiki Ilokano:

Disiembre 7Taga-ugma a GriegoKabassitan a pakadanagan a sebbanganKape1723KomunismoChristopher ColumbusISO 4217Tim Berners-LeePremio NobelElepanteMayo 9ISO 3166Abagatan nga AmerikaLa Union1976Wiki2012Instrumento ti musikaMayo 23Michael JacksonHunio 4Baden-WürttembergAustriaOman18831953Catalogue of LifeMcDonald'sPasismoNorwegaTattao nga Ilokano1979William McKinleyGresiaBaybay MediteraneoAnarkismoPagsasao nga OlandesTsinaSakitBarbentaneEnero 18TangkePagsasao a TagalogNazi nga AlemaniaKawawConfuciusMaine1912Giacomo PucciniKarayan YangtzeMarso 1PutbolBillit2008ZhengzhouWoodrow WilsonAgpayso a Simbaan ni Jesus🡆 More