Template:Digit

From System 4ce Wiki
Jump to: navigation, search


This template gives the digit at a given position of a given positive integer, expressed in a specified numeral system.

  • The first parameter gives the number.
  • The second parameter is the position of the required digit (1 being the rightmost, 2 the one to the left, etc.).
  • The third parameter is the radix of the numeral system (default:10), 2 for binary, 8 for octal, 16 for hexadecimal.

For a radix > 10, the value is given in decimals, for instance, 15 in the hexadecimal system will give for the rightmost digit 15 (which should be "F")

Usage:
Template:Tlx
All parameters must be positive integers.

Examples

Large numbers of type integer

Special care has been taken to make the result exact even for large numbers of type integer.

Limitation

This template applies function mod with as second argument the third parameter and a power of it. Therefore it does not work properly if one of these is equal to one of the values for which mod does not work properly. Known values are 2^n-1 and 2^n+1 for n >= 32:

At least for powers with base <= 30 there are no errors with the test value 17 as first argument, see Help:Mod/powers.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox