This site is supported by donations to The OEIS Foundation.

Template:Digit as char/doc

From OeisWiki
Jump to: navigation, search

This documentation subpage contains instructions, categories, or other information for Template:Digit as char. [<Edit> Template:Digit as char]

[⧼Purge⧽ Template:Digit as char/doc]

The {{digit as char}} base conversion template converts a given digit (as integer) into the 0-indexed character (with index = digit - offset) from an optionally provided conversion string which defaults to

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

if 0 ≤ digit - offset < length of string, otherwise digit is returned as integer surrounded by : (colon).

Usage

{{digit as char|digit as integer (default 0)|integer offset (default 0)|optional conversion string}}

Valid input

  • First argument: digit (default 0) as integer, where digitoffset
Negative integer digits are used with balanced numeral systems (e.g. for balanced ternary numeral system).
  • Second argument: offset as integer (default 0)
  • Third argument: String of characters (conversion string) with default value
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Examples

Examples with valid input

Code Result Comment
{{digit as char}} 0 (0 as default value and offset)
{{digit as char|0|0|}} :0: (empty conversion string)
{{digit as char|7}} 7 (0 as default offset)
{{digit as char|10}} A  
{{digit as char|10|0|}} :10: (empty conversion string)
{{digit as char|35}} Z  
{{digit as char|35|0|}} :35: (empty conversion string)
{{digit as char|36}} a  
{{digit as char|61}} z  
{{digit as char|62}} :62:  
{{digit as char|89}} :89:  
{{digit as char|239}} :239:  
{{digit as char|-1|-1|−0+}} (see balanced ternary numeral system)
{{digit as char|0|-1|−0+}} 0 (see balanced ternary numeral system)
{{digit as char|+1|-1|−0+}} + (see balanced ternary numeral system)
{{digit as char|-1|-1|∨o∧}} (see balanced ternary numeral system)
{{digit as char|0|-1|∨o∧}} o (see balanced ternary numeral system)
{{digit as char|+1|-1|∨o∧}} (see balanced ternary numeral system)
{{digit as char|0|0|αβγδεζηθικλμνξοπρστυφχψω}} α (see base 24)
{{digit as char|5|0|αβγδεζηθικλμνξοπρστυφχψω}} ζ (see base 24)
{{digit as char|23|0|αβγδεζηθικλμνξοπρστυφχψω}} ω (see base 24)
{{digit as char|0|0|abcdefghijklmnopqrstuvwxyz}} a (see base 26)
{{digit as char|3|0|abcdefghijklmnopqrstuvwxyz}} d (see base 26)
{{digit as char|25|0|abcdefghijklmnopqrstuvwxyz}} z (see base 26)

Examples with invalid input

Code Result Comment
{{digit as char|-2|-1|∨o∧}} :-2:
{{digit as char|+2|-1|∨o∧}} :2:
{{digit as char|2.718}} :2.718:
{{digit as char|3.14}} :3.14:
{{digit as char|-5}} :-5:
{{digit as char|-2.718}} :-2.718:
{{digit as char|-3.14}} :-3.14:
{{digit as char|-2.718|-3}} :-2.718:
{{digit as char|-3.14|-4}} :-3.14:
{{digit as char|a}} Expression error: Unrecognized word "a".

Code


{{#ifexpr: ( {{#len:{{{3|0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}}}}} > 0 ) and <!-- 
          --> ( ( {{{1|0}}} ) = floor ( {{{1|0}}} ) ) and ( ( ( {{{1|0}}} ) - ( {{{2|0}}} ) ) >= 0 ) and <!--
          --> ( ( ( {{{1|0}}} ) - ( {{{2|0}}} ) ) <  {{#len:{{{3|0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}}}}} ) 
| {{#sub:{{{3|0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}}}|{{#expr: ( {{{1|0}}} ) - ( {{{2|0}}} ) }}|1}} 
| <nowiki>:</nowiki>{{#expr: {{{1|0}}} }}<nowiki>:</nowiki> 
}}

See also


External links