Formatted numeric output: Difference between revisions

Add SmallBASIC
m (→‎{{header|Wren}}: Minor tidy)
(Add SmallBASIC)
 
(2 intermediate revisions by 2 users not shown)
Line 422:
 
=={{header|BASIC}}==
==={{header|ANSI BASIC}}===
{{works with|Decimal BASIC}}
<syntaxhighlight lang="basic">
100 REM Formatted numeric output
110 LET N = 7.125
120 PRINT USING ("%%%%.###"): N
130 PRINT USING ("****.###"): N
140 PRINT USING ("####.###"): N
150 PRINT USING ("+%%%.###"): N
160 PRINT USING ("+%%%.###"): -N
170 PRINT USING (".###^^^^^"): N
180 PRINT USING ("#.###^^^^^"): N
190 PRINT USING ("##.###^^^^^"): N
200 PRINT USING ("+.###^^^^^"): -N
210 END
</syntaxhighlight>
{{out}}
<pre>
0007.125
***7.125
7.125
+007.125
-007.125
.713E+001
7.125E+000
71.250E-001
-.713E+001
</pre>
 
==={{header|BaCon}}===
BaCon can use C style <tt>printf</tt> format specifiers.
Line 562 ⟶ 591:
==={{header|Run BASIC}}===
<syntaxhighlight lang="runbasic">print right$("00000";using("#####.##",7.125),8) ' => 00007.13</syntaxhighlight>
 
==={{header|SmallBASIC}}===
<syntaxhighlight lang="qbasic">
print format("00000.000", 7.125)
</syntaxhighlight>
 
==={{header|TI-89 BASIC}}===
Line 1,854 ⟶ 1,888:
write(n:0:fractionalPlaces);
end;</syntaxhighlight>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
##
var Pi := 3.1415926536;
Println($'{Pi,8:f2}');
Println($'{Pi,-8:f3}!');
</syntaxhighlight>
{{out}}
<pre>
3.14
3.142 !
</pre>
 
=={{header|Perl}}==
25

edits