Numbers

These puzzles provide means for various operations with numbers in your scenario.

Puzzles available in the Numbers category

Contents

Puzzles Reference

number

This universally used puzzle provides the means to supply some number to your Puzzles scenario.

Puzzle to create numbers

Numbers can be written without decimals (integers) or with decimals (floating-point numbers). Extra large or extra small numbers can be written with scientific (exponent) notation.

Using number block

angle

This puzzle allows you to visually define angle (in degrees).

Puzzle to create angle values

arithmetic operation (with two inputs)

This puzzle allows you to perform elementary arithmetic operations: addition (+), subtraction (-), multiplication (×) and division (÷), as well as exponentiation (^).

Puzzle to perform various math operations

Please note that floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision.

Using operation block with two inputs

arithmetic operation (with single input)

This puzzle allows you to perform the following mathematical operations: square root (√), absolute value aka modulus (|x|), sign change aka negation (-), natural logarithm (ln), decimal logarithm (log10), natural exponential function (e^), and power of ten (10^).

Puzzle to perform math operation on single value

Examples:

Using operation block with a single input

Please note that floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision.

round (to integer)

This puzzle rounds a specified number. The round variant rounds a number to the nearest integer: 2.49 will be rounded down (producing 2), and 2.5 will be rounded up (producing 3). The round up variant rounds a number upward to the nearest integer: 2.1 will be rounded up (producing 3). The round down variant rounds a number downward to the nearest integer: 2.9 will be rounded down (producing 2).

Puzzle to round a value

Examples:

Rounding example

round with precision

This puzzle rounds a given number using the specified precision.

Puzzle to round with precision

Examples:

Rounding example script 1

Floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision as follows:

Rounding example script 2

check

This puzzle checks whether a specified number is even, odd, prime, whole, positive, negative, or divisible by some other number. The result is true if this is the case and false if not. For using with Logic puzzles.

Check - puzzle

Examples:

Using check block

clamp

This puzzle constraints a number to be between the specified limits (inclusive).

Clamp - puzzle

Examples:

Using clamp block

map range

This puzzle maps a given value from one range to another.

Map range puzzle

Example: converting position of the slider that moves from -10 to 10 units along axis X to percentage value from 0% to 100%.

Map range example

random integer

This puzzle returns a random integer number between specified numbers (inclusive both limits).

Puzzle to generate random integer

Note: supplying non-integer limits is possible, although this extends the range as this puzzle performs some additional rounding under the hood.

Examples:

Random integer example script

random fraction

This puzzle returns a random floating-point number between 0 (inclusive) and 1 (exclusive).

Puzzle to generate random fraction

In the following example this puzzle is used to generate a random color for a material:

Random fraction example script

remainder

This puzzle finds the remainder after division of one number by another (aka the modulo operation).

Logic block to calculate division remainder

Examples:

Calculating remainder

operations on list

Performs an operation on the numbers of a specified list.

List operation visual logic block

Examples:

Examples of visual programming scripts using operations on list

trigonometric functions

This puzzle allows you to calculate the values of the trigonometric functions sine (sin), cosine (cos), and tangent (tan), as well as the values of their inverse counterparts arcsine (asin), arccosine (acos), and arctangent (atan). The puzzle expects (or returns) values expressed in degrees.

Puzzle to calculate trigonometric functions

Examples:

Calculating various trigonometric functions

Please note that floating-point arithmetic is not always 100% accurate, and may produce unpredictable results when comparing numeric values. To get rid of those precision issues, you may use rounding with precision.

constants

This puzzle returns the following mathematical constants: pi (π), Euler's number e, the golden ratio (φ), square root of 2, square root of ½, and infinity value (∞).

Math constants puzzle

Examples:

Example scripts using math constants

vector

This puzzle returns a new three-dimensional vector which consists of the given X, Y, Z coordinates.

Puzzle to create vectors

set vector value

This puzzle set the given value (x, y, z coordinate or length) for the given vector.

Puzzle to set vector value

get vector value

This puzzle returns the given value taken or calculated from the given vector.

Puzzle to get vector value

Returned values:

vector math

This puzzle performs a math operation between two vectors and returns a new vector.

Puzzle to do vector math

Operations:

Having Troubles with Puzzles?

Seek help on the forums!