Tuesday, October 9, 2012

Use of PRINT USING

In order to limit output to a specified number of digits, you use the PRINT USING command.

Consider for a moment dividing 17 by 13. The result is 1.307692307692308. Do you really need *all* of those digits to the right of the decimal place? Most likely, unless you are doing extremely precise scientific
calculations, you don't. If you are working with currency, you definitely do not. By including the USING qualifier in the PRINT directive, you can limit the output to a reasonable length. See the difference here:

PRINT "17 / 13 = "; 17 / 13
PRINT
PRINT
PRINT USING "17 / 13 = ##.##"; 17 / 13



The first PRINT statement displays the whole long string of decimal places. The PRINT USING statement limits the output to merely two decimal places.