Non-decimal radices/Convert: Difference between revisions

forth
(sort)
(forth)
Line 63:
Put_line("1a (base 16) is decimal" & Integer'image(To_Decimal("1a", 16)));
end Number_Base_Conversion;</ada>
 
=={{header|Forth}}==
Forth has a global user variable, BASE, which determines the radix used for parsing, interpretation, and printing of integers. This can handle bases from 2-36, but there are two words to switch to the most popular bases, DECIMAL and HEX.
42
2 base !
. // 101010
hex
. // 2A
decimal
 
Many variants of Forth support literals in some bases, such as hex, using a prefix
$ff . // 255
 
=={{header|Java}}==
Anonymous user