Formatted numeric output: Difference between revisions

Content added Content deleted
(→‎min: update)
(Formatted numeric output in various dialects BASIC (BASIC256, QBasic, True BASIC, XBasic and Yabasic))
Line 362: Line 362:
-0003.142
-0003.142
</pre>
</pre>

==={{header|BASIC256}}===
<syntaxhighlight lang="basic">n = 7.125
print rjust(string(n), 8, "0") # => 00007.125
print zfill(string(n), 8) # => 00007.125</syntaxhighlight>


==={{header|Chipmunk Basic}}===
==={{header|Chipmunk Basic}}===
Line 383: Line 388:


{{out}}
{{out}}
<pre>
<pre>00007.125</pre>
00007.125
</pre>


==={{header|FutureBasic}}===
==={{header|FutureBasic}}===
Line 394: Line 397:
HandleEvents</syntaxhighlight>
HandleEvents</syntaxhighlight>
Output:
Output:
<pre>
<pre>00007.125</pre>
00007.125
</pre>


==={{header|IS-BASIC}}===
==={{header|IS-BASIC}}===
Line 465: Line 466:
<syntaxhighlight lang="purebasic">RSet(StrF(7.125,3),8,"0") ; Will be 0007.125</syntaxhighlight>
<syntaxhighlight lang="purebasic">RSet(StrF(7.125,3),8,"0") ; Will be 0007.125</syntaxhighlight>


==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">n = 7.125
PRINT USING ("0000#.###"); n ' => 00007.125</syntaxhighlight>


==={{header|Run BASIC}}===
==={{header|Run BASIC}}===
<syntaxhighlight lang="runbasic">print right$("00000";using("#####.##",7.125),8) ' => 00007.13</syntaxhighlight>
<syntaxhighlight lang="runbasic">print right$("00000";using("#####.##",7.125),8) ' => 00007.13</syntaxhighlight>



==={{header|TI-89 BASIC}}===
==={{header|TI-89 BASIC}}===
Line 474: Line 479:
<syntaxhighlight lang="ti89b">right("00000" & format(7.12511, "f3"), 9)</syntaxhighlight>
<syntaxhighlight lang="ti89b">right("00000" & format(7.12511, "f3"), 9)</syntaxhighlight>


==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">LET n = 7.125
PRINT USING ("0000#.###"): n ! => 0007.125
END</syntaxhighlight>


==={{header|VBA}}===
==={{header|VBA}}===
Line 534: Line 543:
00007.125
00007.125
</syntaxhighlight>
</syntaxhighlight>

==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "progname"
VERSION "0.0000"

DECLARE FUNCTION Entry ()

FUNCTION Entry ()
n! = 7.125
PRINT FORMAT$("0000#.###", n!)
END FUNCTION
END PROGRAM</syntaxhighlight>
{{out}}
<pre>00007.125</pre>

==={{header|Yabasic}}===
<syntaxhighlight lang="basic">n = 7.125
print n using ("#####.###") // => 7.125
print str$(n, "%09.3f") // => 00007.125</syntaxhighlight>


==={{header|ZX Spectrum Basic}}===
==={{header|ZX Spectrum Basic}}===