$base

From Scriptwiki
Revision as of 22:28, 17 February 2008 by Aca20031 (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Base allows you to change the radix of a number, up to base 36. The limit is base 36 because the only characters which are supported are A-Z and 0-9, 36 total.

$base(N,inbase,outbase,[zeropad],[precision])
  • N is the number to change the base of.
  • inbase is the radix of N currently.
  • outbase is the radix you wish to change N to, from inbase.
  • zeropad is the number of digits the final result should be. If the result is less than zeropad digits in length, 0s are added to the front of the result. If the result is greater than zeropad digits, it is all returned.
  • precision is the number of decimals to return.

Base 10 is the common decimal numbering system most people use.

Example

To convert 255 (decimal, 10) to binary (base 2):

$base(255,10,2) -> 11111111

To convert 255 (decimal, 10) to hexadecimal (base 16):

$base(255,10,16) -> FF