Non-decimal radices/Output: Difference between revisions
J -- hopefully useful and appropriate this time
(bah -- error... will revisit after i have this right) |
(J -- hopefully useful and appropriate this time) |
||
Line 216:
f :: Int -> IO ()
f n = printf " %3o %2d %2X\n" n n n -- binary not supported</lang>
=={{header|J}}==
J can natively break out numbers using a specific base
2 #.inv 12
1 1 0 0
3 #.inv 100
1 0 2 0 1
16 #.inv 180097588
10 11 12 1 2 3 4
However, this numeric representation would not satisfy most people's idea of "formatting", for most bases. It might be useful, however, for bases less than 10:
8 #.inv 4009
7 6 5 1
-.&' '": 8 #.inv 4009
7651
J also includes some explicit support for hexadecimal numbers
require 'convert'
hfd 180097588
ABC1234
(and a few other hexadecimal related mechanisms which are not relevant here.)
=={{header|Java}}==
|