This site is supported by donations to The OEIS Foundation.
Template:To base 10
[⧼Purge⧽ Template:To base 10]
The {{to base 10}} base conversion template converts a colon ":" separated "digits" real number (expressed in positive integer base (radix) ) into its base 10 representation . The "digits" may be negative (-) or positive (+); this may be useful later on with balanced odd bases (e.g. balanced ternary numeral system). To negate the number as a whole, precede it with --. You may also precede it with ++, which leaves the whole number unchanged. Currently supports up to 32 digits for integer part and up to 32 digits for fractional part.
Usage
- {{to base 10|optional ++ or --, then a colon separated "digits" real number xb in base b|a radix (base) b ≥ 2}}
Valid input
- An optional global sign (++ or --), then a colon separated "digits" real number (in base ) as first argument. A positive integer base (radix) as second argument.
Examples
Examples with valid input
Code Result Comment {{to base 10}} 0 (0 as default value) {{to base 10|3: 7: 4}} 374 (10 as default base) {{to base 10|3:7:4}} 374 (10 as default base) {{to base 10|++ 3:7:4}} 374 (10 as default base) (whole number is posited) {{to base 10|+ 3:7:4}} 374 (10 as default base) (gotcha: (+300) + 70 + 4 = +374, first digit only is posited) {{to base 10|3:+ 7:4}} 374 (10 as default base) {{to base 10|-- 3:7:4}} -374 (10 as default base) (whole number is negated) {{to base 10|- 3: 7: 4}} -226 (10 as default base) (gotcha: (-300) + 70 + 4 = -226, first digit only is negated) {{to base 10|-- -3:7:4}} 226 (10 as default base)
(where - ((-300) + 70 + 4) = 226)
{{to base 10|3:-7:4}} 234 (10 as default base)
(where 300 + (-70) + 4 = 234)
{{to base 10|-- 3:-7:4}} -234 (10 as default base)
(where - (300 + (-70) + 4) = -234)
{{to base 10|3:7:4|10}} 374 {{to base 10|1:0:1|2}} 5 {{to base 10|+1:-1:0:+1|3}} 19 (balanced ternary) {{to base 10|-1:+1:0:-1|3}} -19 (balanced ternary, no -- global sign needed!)) {{to base 10|-- 1:0:1|2}} -5 {{to base 10|1:1:1:0:1:1|2}} 59 {{to base 10|1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1|2}} 4294967295 2 32 - 1 = 4294967295 {{to base 10|1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1|2}} 65535 2 16 - 1 = 65535 {{to base 10|0.1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1|2}} 0.99999999976717 (2 32 - 1) / 2 32 = 0.99999999976717 {{to base 10|0.1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1|2}} 0.99998474121094 (2 16 - 1) / 2 16 = 0.99998474121094 {{to base 10|0.1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:0:1:1:1:1:1:1:1|2}} 0.99999996996485 (2 32 - 2 7 - 1) / 2 32 = 0.99999996996485 {{to base 10|0.0:0:1:1:1:1:1:1:1:1:0:1:1:1:1:1|2}} 0.24949645996094 (2 14 - 2 5 - 1) / 2 16 = 0.24949645996094 {{to base 10|1:5:1|6}} 67 {{to base 10|0.1:5:2:4:1|6}} 0.31802983539095 0 + 1 / 6 + 5 / 6 2 + 2 / 6 3 + 4 / 6 4 + 1 / 6 5 = 0.31802983539095 {{to base 10|-- 0.1:5:2:4:1|6}} -0.31802983539095 {{to base 10|2:35|36}} 107 {{to base 10|17.2:35|36}} 17.082561728395 17 + 2 / 36 + 35 / 36 2 = 17.082561728395 {{to base 10|1:2:59|60}} 3779 {{to base 10|49.1:2:59|60}} 49.01749537037 49 + 1 / 60 + 2 / 60 2 + 59 / 60 3 = 49.01749537037 {{to base 10|49.01:02:59|60}} 49.01749537037 {{to base 10|49.1: 2: 59|60}} 49.01749537037 {{to base 10|49. 1 : 2 : 59|60}} 49.01749537037
Examples with invalid input
Code Result {{to base 10|1:0:1|1}} 2 {{to base 10|1:1:1:0:1:1|1}} 5 {{to base 10|1:5:1|1}} 7 {{to base 10|1:5:1|0}} NAN {{to base 10|1:5:1|-1}} -3 {{to base 10|1:5:1|-6}} 7
Code
See also
- {{from base 10}} base conversion template
External links
- Number Bases Conversion from ConvertXY.com
- Jack Sanders-Reed, Base Conversion (Java applet calculator capable of converting a number from/to any base 2-36.)
- Base Conversion (Convert to/from base two through base sixteen.)
- Base Convert (Convert to/from any integer base greater than 1 or Roman numerals.)