Jump to content

Formatted numeric output: Difference between revisions

Formatted numeric output in various dialects BASIC (BASIC256, QBasic, True BASIC, XBasic and Yabasic)
(→‎min: update)
(Formatted numeric output in various dialects BASIC (BASIC256, QBasic, True BASIC, XBasic and Yabasic))
Line 362:
-0003.142
</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}}===
Line 383 ⟶ 388:
 
{{out}}
<pre>00007.125</pre>
00007.125
</pre>
 
==={{header|FutureBasic}}===
Line 394 ⟶ 397:
HandleEvents</syntaxhighlight>
Output:
<pre>00007.125</pre>
00007.125
</pre>
 
==={{header|IS-BASIC}}===
Line 465 ⟶ 466:
<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}}===
<syntaxhighlight lang="runbasic">print right$("00000";using("#####.##",7.125),8) ' => 00007.13</syntaxhighlight>
 
 
==={{header|TI-89 BASIC}}===
Line 474 ⟶ 479:
<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}}===
Line 534 ⟶ 543:
00007.125
</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}}===
2,130

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.