Category:Math

Gets the result of basic math operations: addition, subtraction, multiplication, division, and exponents.

This block is like a simple calculator and follows all the typical rules of math operations. It gets the result of the operation and can be used wherever a number block is expected.

Parameters

NameDescription
number (2) The two numbers of the math operation

Tips

  • Positive numbers, negative numbers, and decimals are accepted.
  • If a division operation that results in a decimal is used where an integer is expected, the result will be rounded up to the nearest integer. For example, a repeat loop given 4 รท 3 (= 1.3333) will repeat the code 2 times.
  • To make longer operations, math blocks can be used inside of other math blocks in place of a single number.

Found a bug in the documentation? Let us know at documentation@code.org