Numbers

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

Visual programming blocks to calculate numbers

Contents

Puzzles Reference

number

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

Visual logic block 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).

Visual programming block 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 (^).

Visual programming block 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^).

Visual programming block 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).

Visual logic block to round a value

Examples:

Rounding example

round with precision

This puzzle rounds a given number using the specified precision.

Visual logic block 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 - visual programming block

Examples:

Using check block

clamp

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

Clamp - visual programming block

Examples:

Using clamp block

map range

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

Map range visual programming block

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).

Visual programming block 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).

Visual logic block 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.

Visual logic block 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 visual programming block

Examples:

Example scripts using math constants

create vector

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

Visual programming block to create vectors

set vector value

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

Visual programming block to set vector value

get vector value

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

Visual programming block to get vector value

Returned values:

vector math

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

Visual programming block to do vector math

Operations:

Having Troubles with Puzzles?

Seek help on the forums!