User Manual
Print

Converting the Number to an Approximate Value

Round

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"math_js_round\" disabled=\"true\" x=\"-22\" y=\"607\"><field name=\"OP\">round</field><value name=\"ARG0\"><shadow type=\"math_number\" disabled=\"true\"><field name=\"NUM\">0</field></shadow></value></block></xml>"}
				
			

This block is used to replace the number with an approximate value. If the fractional part is more than one half, the number will increase.

Parameters: Condition: 

            • Number (Default: 0)
            • Square root (Default)/sin/cos/tan/atan2/integer ÷/integer ×

Output: Number
Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"math_js_op\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" op-type=\"unary\"></mutation><field name=\"OP\">sqrt</field><value name=\"ARG0\"><shadow type=\"math_number\"><field name=\"NUM\">4</field></shadow></value></block></value></block></statement></block></xml>"}
				
			

The output:

Square Root - Output