Rounds numbers to the number of decimal places you choose and lists them in two columns: the number as typed, and the rounded number placed so that the decimal points line up (whole numbers end in the column before the point). Give the number of places once, then type numbers one after another; the program keeps asking until you stop it.
Corrected: line 220 was printed LET A=N+5.5*10^-(DP+1), which adds 5.5 in the first dropped place and so rounded up numbers such as 1.0047 (to two places, 1.01). It now adds 5, the usual rounding; the article’s sample output is unchanged.
Published in The Plotter September 1993 (Rounding Numbers).
Source Code
10 PRINT " ******************"
20 PRINT " *ROUNDING NUMBERS*"
30 PRINT " ******************"
40 REM DICK WAGNER 7/93
100 REM N=NUMBER TO BE ROUNDED
110 REM DP=DIGITS TO THE RIGHT OF DECIMAL POINT
120 REM R=VALUE ROUNDED
200 PRINT ;"HOW MANY PLACES TO RIGHT OF DECIMAL POINT FOR ROUNDING? ";: INPUT DP: CLS
205 PRINT "INPUT NUMBER TO BE ROUNDED": PRINT
210 INPUT N;
220 LET A=N+5*10^-(DP+1)
230 LET R=INT (A*10^DP)/10^DP
300 LET N$=STR$ R
310 FOR L=1 TO LEN N$
320 IF N$(L)="." THEN GO TO 350
325 NEXT L
330 PRINT N;: PRINT TAB (20-LEN N$);N$: GO TO 210
350 PRINT N;: PRINT TAB (21-L);N$: GO TO 210Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


