**Thunkable for Android **❤

# Math

Math blocks have a wide array of functions from basic numbers and conditional tests to a variety of math operators and formatters. Math blocks are also useful for introducing randomness into your app

#### Basic number

Can be used as any positive or negative number (decimals included). Double clicking on the "0" in the block will allow you to change the number

#### Conditional test

(a) (b) (c) (d) (e) (f) (g)

(a) **Equals** Tests whether two numbers are `equal`

and returns true or false

(b) **Does not equal** Tests whether two numbers are `not equal`

and returns true or false

(c) **Greater than **Tests whether the first number is `greater than`

the second number and returns true or false

(d) **Greater than or equal** Tests whether the first number is `greater than or equal to`

the second number and returns true or false

(e) **Less than** Tests whether the first number is `less than`

the second number and returns true or false

(f) **Less than or equal **Tests whether the first number is `less than or equal to`

the second number and returns true or false

(g) **Is a number? **Returns true if the given object `is a number`

, and false otherwise

#### Math operators

(a) (b) (c) (d) (e)

(a) **Addition** Returns the result of `adding`

any amount of blocks that have a number value together. Blocks with a number value include the basic number block, length of list or text, variables with a number value, etc

(b) **Subtraction** Returns the result of `subtracting`

the second number from the first

(c)** Multiplication **Returns the result of `multiplying`

any amount of blocks that have a number value together

(d)** Division **Returns the result of `dividing`

the first number by the second

(e) **Division with no remainder** Returns the result of dividing the first number by the second and discarding any fractional part of the result

(f)(g) (h) (i) (j) (k)

(f) **Exponent **Returns the result of the first number `raised to the power`

of the second

(g) **Natural log** Returns the `natural logarithm`

of a given number, that is, the logarithm to the base e (2.71828...)

(h)** e^ **Returns e (2.71828...) raised to the power of the given number

(i) **Square root** Returns the `square root`

of the given number

(j) **Absolute value** Returns the `absolute value`

of the given number

(k) **Negative** Returns the `negative`

of a given number

(l) (m) (n) (o) (p)

(l) **Max** Returns the `largest value`

of a set of numbers. If there are unplugged sockets in the block, max will also consider 0 in its set of numbers

(m) **Min** Returns the `smallest value`

of a set of numbers. If there are unplugged sockets in the block, min will also consider 0 in its set of numbers

(n) **Round** Returns the given number `rounded`

to the closest integer. If the fractional part is <.5 it will be rounded down. It it is >.5 it will be rounded up. If it is exactly equal to .5, numbers with an even whole part will be rounded down, and numbers with an odd whole part will be rounded up

(o) **Ceiling** Returns the `smallest integer`

that's greater than or equal to the given number

(p) **Floor** Returns the `greatest integer`

that's less than or equal to the given number

(q) (r) (s) (t) (u) (v) (w)

(q) **Sine** Returns the `sine`

of the given number in degrees

(r) **Cosine **Returns the `cosine`

of the given number in degrees

(s) **Tangent **Returns the `tangent`

of the given number in degrees

(t) **Arcsine **Returns the `arcsine`

of the given number in degrees

(u) **Arccosine **Returns the `arccosine`

of the given number in degrees

(v) **Arctangent** Returns the `arctangent`

of the given number in degrees

(w) **Arctangent 2 **Returns the `arctangent`

of y/x, given y and x

#### Reformat number

(a) (b) (c)

(a) **Decimal **Formats a number as a `decimal`

with a given number of `places`

after the decimal point. The number of places must be a non-negative integer. The result is produced by rounding the number (if there were too many places) or by adding zeros on the right (if there were too few)

(b) **Radians to degrees **Returns the value in degrees of the given number in radians. The result will be an angle in the range [0, 360)

(c) **Degrees to radians **Returns the value in radians of the given number in degrees. The result will be an angle in the range [-π , +π)

#### Introduce randomness

(a) (b) (c)

(a) **Random integer** Returns a `random integer`

value between the given values, inclusive. The order of the arguments doesn't matter

(b) **Random fraction** Returns a random value between 0 and 1

(c) **Random sequence **Use this block to generate repeatable sequences of random numbers. You can generate the same sequence of random numbers by first calling random set seed with the same value. This is useful for testing programs that involve random values