EZ Math Movie, Tutorials, Printing, Printing a Number


Clearing the printer

If you are going to use the printer, it is a good idea to clear it near the start of your program. Then, if you run the program several times, the program will always start out with a clear printer, and you won't clutter your view with the printing output from pervious program runs.

The printer is cleared with the command clearPrinter:

clearPrinter();

The number is rounded when printed.

Values are printed with the command printNumber. This command accepts a value and sends it to the printer. By default values are rounded to two decimal places, although this can be changed. Here is what the command printNumber looks like:

printNumber(2.345);

The above code would print the number 2.35:

2.35

Controlling the number of decimals

You can control the number of decimals that will be printed by using the command setNumDecimals. The following command would set the number of decimals to 3:

setNumDecimals(numDecimals);

After the above command executed, if you were to print the number 9.1234, you would see:

9.123

Running the example program

The example program demonstrates how a value is rounded. The first printing uses the default number of decimals, and the second shows how to control the number of decimals with setNumDecimals.

The example program uses the command printNewLine. It makes the printing skip to the next line, and that is explained further in a following printing tutorial.


The example program

0ptions
Angle measurement: Degrees Radians

Go on input

Bounds:
Sorry, apparently this browser does not support HTML 5 canvas tag graphics.
Printer

Edit: Runtime          View: Starter Suggestion

To runtime:

Storage:

Editor width: Normal Wide


		

	


		

	


		

	

And....

Next tutorial: Printing text


All contents of EZ Math Movie are copyrighted: Copyright 2011, Edward A. Zobel. All rights reserved.



Other sites you may find interesting

Zona Land Education Like Math and Physics?

Zona Land Education offers explanations, diagrams, and animations on these topics.
And it is all presented in a clear and casual manner.

Here is the link: zonalandeducation.com




EZ Programing Demos Want to learn about programing computers?

EZ Programing Demos has an animated, slow motion, interactive programing language demonstrator.
The site presents basic ideas at a beginner's level.

Here is the link: ezprogramingdemos.com



Custom Search

Name:
Domain:

Name
0


Name:
Name
0