The PRINT USING form is used to format the results of calculations where real number results
would produce an untidy array of decimal places. It is a complicated concept that is best appreciated
through practical examples, since the technical form:
PRINT [#stream expression,,
I
[<print list)][using clause,][separator,]
Could be justly described as non-user-friendly, especially since the using clause, further divides
down to:
USING <string expresion>; [<using list>]
where the <using list> further subdivides to
<expression>[<separator><expression>]*
Try the following:
PRINT 123.456, USING “###.##“;4567.896
the result..
123.456 %4567.90
. . ..illustrates several points. Firstly the item to be printed before the USING clause is not affected.
Secondly, the USING clause allocates the number of ‘output’ positions available for the print item
following (which may be a variable of course), and if this item exceeds the allocated space to the left
of the decimal point, it still displays, but uses the % to indicate that an overflow has occured. Next,
the comma after 12 3
.4
5 6 caused the following number to be printed at the start of the next print
zone. If it had been a semi-colon, the number would have been printed alongside the 12 3
.4
5 6 one
space to the right. Numbers are always separated by one space when printed on the same line
-
for
obvious reasons!
Finally note that the expression is rounded and does not simply discard the digit(s) beyond the last
place used in the format.
Try this:
PRINT 123.456, USING “#####.##+“;4567.899
. . ..and the sign appears at the end of the formatted number. A minus sign will precede a negative
number by default.
PRINT USING is a very useful facility in producing any form of tabulated result output, It will
always warn you if the format specified is too restrictive (using the % ).
Содержание CPC464
Страница 1: ......
Страница 32: ...or you can type 3e1 1e1 ENTER 300 2 3000x1000 Type 3e3 1e3 ENTER 3000000 3 3000x0 001 Type 3e3 1e 3 ENTER 3 ...
Страница 102: ...PRINT 10 AND 12 Results in 8 PRINT 10 AND 1000 Results in 8 again ...
Страница 118: ...TO DO DRAW THIS PAGE ...
Страница 219: ...actual value may be made to vary during the execution of a program ...
Страница 240: ...Text and WINDOW planner Mode 2 80 Columns ...
Страница 241: ......
Страница 245: ...Sound envelope Music planner sheet ...