This article is about how numbers are used in programming. For the blocks that deal with numbers, see Operators Blocks.
For more information, see Number on Wikipedia.

Numbers are mathematical values used for counting and measuring and are ubiquitous in programming. In Scratch projects, numbers are the inputs and outputs of many blocks. Mathematical expressions can be constructed with operator blocks and evaluated with numbers. Numbers are also used as identifiers in Scratch, such as the (costume [number v]) block, which identifies the placement of a costume in a sprite. Numbers can be stored in variables and lists for later use.

Classification

For more information, see List of types of numbers on Wikipedia.

Numbers can be categorized by their properties, with some common classifications listed below:

  • Natural — Numbers for counting, e.g. 1, 2, 3, 4, 5. Sometimes the number 0 is included.
  • Integer — Positive and negative counting numbers, e.g. -2, -1, 0, 1, 2.
  • Rational — Numbers that can be represented by a fraction such as 23.
  • Real — All numbers that can be represented on a number line such as -519, 0, 8, 223.95.
A number line.

Representation

In Scratch projects, numbers are stored in double-precision floating-point format (usually abbreviated to "double float", "double", or "float"). Numbers may also be stored as Booleans or strings however will be casted to double floats when needed, such as in operator blocks.

Mathematical Functions

The following table lists various mathematical functions found in Scratch. It is not inclusive of all functions.

Math Operations in Scratch
Concept Block
addition (() + ())
subtraction (() - ())
multiplication (() * ())
division (() / ())
square root ([sqrt v] of ())
modulus (() mod ())
Cookies help us deliver our services. By using our services, you agree to our use of cookies.