Jump to content

User:Kri/Backup of ConvertToBaseI/doc

From Wikipedia, the free encyclopedia

Converts an integer from decimal to another base.

Usage[edit]

{{ConvertToBaseI|number|base|...}} (see parameters)

Parameters[edit]

  • basename
    The name of base, to be written in subscript after the number; to skip writing the base, set this parameter to 0. If this parameter is omitted, the base will be written in subscript after the number in its decimal number representation.
  • digitset
    The name of the template containing the set of digits to use, for example {{HexadecimalDigit}}. If this parameter is omitted, each digit will be written in its decimal number representation.
  • separator
    A separator to be written between the digits with an certain period. If this parameter is omitted, no separator will be written between the digits.
  • sepperiod
    The period of the separator (if given). If this number non-positive, or the parameter is omitted, the period of the separator will be 1.
  • digitseparatorcount
    Help variable for the template to keep track of how many digits it has written (from right to left) since the last separator. Omit this parameter for normal usage of the template.

Examples[edit]

  • {{ConvertToBaseI|100|2|basename=0}} gives 100
  • {{ConvertToBaseI|100|4}} gives 100
  • {{ConvertToBaseI|100|4|separator=,|sepperiod=3}} gives 100
  • {{ConvertToBaseI|100|16|digitset=Hexadecimal|basename=hex}} gives 100

Special cases[edit]

Negative numbers will be start with a minus sign to indicate their sign:

  • {{ConvertToBaseI|100|4}} gives −100

Zero will always give the digit corresponding to the value 0:

  • {{ConvertToBaseI|0|16|digitset=Hexadecimal}} gives {{#if Hexadecimal |016|0}}

Numbers equal to or greater than 228 (268,435,456) are to big to be handled:

  • {{ConvertToBaseI|268435456|4}} gives N/A

See also[edit]