Template:DecHex/doc

Category:Template documentation#DecHex/doc

Convert an integer from decimal to hexadecimal.

Usage


{{DecHex |1= |2= }}

  • If the input is an empty string, the result is an empty string.
  • Non-integer and negative values are truncated to unsigned 64-bit integers (with a maximum of 16 hexadecimal digits returned).
  • The returned hexadecimal digits A to F are in upper case.
  • However the precision is limited to the most significant 44 bits (11 hexadecimal digits), and less significant digits are rounded when converted back to decimal; the inverse conversion from hexadecimal to decimal is warrantied to be a distinct positive integer string only within this limited range; values in larger ranges will result in an decimal floating-point string, possibly negative and with a limited precision in terms of significant digits.
  • For example:
    • {{DecHex|17592186044414}} returns FFFFFFFFFFE and {{HexDec|{{DecHex|17592186044414}}}} returns 17592186044414
    • {{DecHex|17592186044415}} returns FFFFFFFFFFF and {{HexDec|{{DecHex|17592186044415}}}} returns 17592186044415
  • But higher integer values are rounded when converted back to decimal from hexadecimal, even if the hexadecimal string is correct in the positive 64-bit range:
    • {{DecHex|17592186044416}} returns 100000000000 and {{HexDec|{{DecHex|17592186044416}}}} returns 17592186044415
    • {{DecHex|140737488355327}} returns 7FFFFFFFFFFF and {{HexDec|{{DecHex|140737488355327}}}} returns 1.4073748835533e+14

Template parameters

ParameterDescriptionDefaultStatus
1a decimal integer to convertemptyoptional
2the minimum count (1 to 16) of hexadecimal digits to return (left-padded with zeroes when needed)1optional

Additional information

The template is intended to be used in the following namespaces: no namespace specified

The template is intended to be used by the following user groups: no user group specified

Relies on:

See also

Localization

This template is not intended to be localized.

Category:Template documentation