Formatted numeric output: Difference between revisions
Content added Content deleted
(Formatted numeric output in various dialects BASIC (BASIC256, QBasic, True BASIC, XBasic and Yabasic)) |
(add RPL) |
||
Line 2,137: | Line 2,137: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|RPL}}== |
|||
Number formatting in RPL is at 1980s standards (ANSI BASIC X3J2, 1983 to be precise). If the user wants something else, she/he has to write some code, formatting the number as a string. |
|||
≪ 1 CF '''IF''' OVER 0 < '''THEN''' 1 SF 1 - '''END''' |
|||
SWAP ABS →STR |
|||
'''WHILE''' DUP2 SIZE > '''REPEAT''' |
|||
"0" SWAP + '''END''' |
|||
'''IF''' 1 FS? '''THEN''' "-" SWAP + '''END''' |
|||
SWAP DROP |
|||
≫ ''''TASK'''' STO |
|||
{{in}} |
|||
<pre> |
|||
7.125 9 TASK |
|||
-7.125 9 TASK |
|||
</pre> |
|||
{{out}} |
|||
<pre> |
|||
2: "00007.125" |
|||
1: "-0007.125" |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<syntaxhighlight lang="ruby">r = 7.125 |
<syntaxhighlight lang="ruby">r = 7.125 |