Non-decimal radices/Output: Difference between revisions

m
No edit summary
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
Line 1,712:
ABCD
FFFFFFFF
</pre>
 
=={{header|RPL}}==
Unsigned integers are displayed in binary, octal, decimal or hexadecimal base depending on the state of 2 user flags, which can be easily configured by using resp. the <code>BIN</code>, <code>OCT</code>, <code>DEC</code> or <code>HEX</code> instruction. It is not possible to display several numbers in different bases simultaneously, unless you "freeze" their appearance by converting them to a string:
#314 DUP BIN →STR " " +
OVER OCT →STR + " " +
OVER DEC →STR + " " +
OVER HEX →STR +
{{out}}
<pre>
1: "# 100111010b # 472o # 314d # 13Ah"
</pre>
 
Line 1,905 ⟶ 1,916:
{{libheader|Wren-fmt}}
Wren has no non-decimal number conversions in its standard library so this uses a module I wrote myself to reproduce the Haskell table.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Conv, Fmt
 
System.print(" 2 7 8 10 12 16 32")
9,476

edits