Skip to content

Number

As its name implies, the number data type is for storing a number.

Unlike many other programming languages, Modulo1 does not have different types of numerical data-types like integers, floating-point etc. Instead, Modulo1 silently handles the conversions between integer and floating point so that you can focus on more important things.


Syntax

To create a new number:

1
var myAge = 34;

To change an existing number:

1
myAge = 36;

To delete a number:

1
delete myAge;

To create a duplicate of a number

1
yourAge = myAge;

To create a new number based on the result of a mathematical calculation:

1
var truckHeight = (24 * 13) / 2.54;

To multiply this variable by another number:

1
truckHeight *= 75;

To divide this variable by another number:

1
truckHeight /= 3.2;

To increment this variable by another number:

1
truckHeight += 12;

To increment this variable by 1:

1
truckHeight++;

To decrement this variable by another number:

1
truckHeight -= 7;

To decrement this variable by 1:

1
truckHeight--;

Properties

A property is a special feature of a variable that can be used to get and/or set some aspect of that variable.

type

The type property can be used to find out the data-type of a particular number variable. The result will always be "number"

1
var result = truckHeight.type;

Special Values

These are variables that are built into the core and that can be accessed from any code block

E

The E variable is Euler's number

1
var result = number.E;

PI

The PI variable is Pi

1
var result = number.PI;

SQRT2

The SQRT2 variable is the square root of 2

1
var result = number.SQRT2;

SQRT1_2

The SQRT1_2 variable is the square root of 1/2

1
var result = number.SQRT1_2;

LN2

The LN2 variable is the natural logarithm of 2

1
var result = number.LN2;

LN10

The LN10 variable is the natural logarithm of 10

1
var result = number.LN10;

LOG2E

The LOG2E variable is the base 2 logarithm of E

1
var result = number.LOG2E;

LOG10E

The LOG10E variable is the base 10 logarithm of E

1
var result = number.LOG10E;

Functions

abs( number x )

The abs function returns the absolute value of x

1
var result = number.abs(75.2378);

acos( number x )

The acos function returns the arccosine of x, in radians

1
var result = number.acos(24);

acosh( number x )

The acosh function returns the hyperbolic arccosine of x

1
var result = number.acos(13.57);

asin( number x )

The asin function returns the ascsine of x, in radians

1
var result = number.asin(75.2);

asinh( number x )

The asinh function returns the hyperbolic arcsine of x

1
var result = number.asinh(25);

atan( number x )

The atan function returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians

1
var result = number.atan(32);

atan2( number y, number x )

The atan2 function returns the the arctangent of the quotient of its arguments

1
var result = number.atan2(7, 16.5);

atanh( number x )

The atanh function returns the hyperbolic arctangent of x

1
var result = number.atanh(100);

cbrt( number x )

The cbrt function returns the cubic root of x

1
var result = number.cbrt(9999);

ceil( number x )

The ceil function returns x, rounded up

1
var result = number.ceil(76.2324);

cos( number x )

The cos function returns the cosine of x (x is in radians)

1
var result = number.cos(0.5);

cosh( number x )

The cosh function returns the hyperbolic cosine of x

1
var result = number.cosh(1.156);

exp( number x )

The exp function returns E to the power of x

1
var result = number.exp(3);

floor( number x )

The floor function returns x, rounded down

1
var result = number.floor(87.23);

log( number x )

The log function returns the natural logarithm (base E) of x

1
var result = number.log(100);

max( number x, number y, number z, ...)

The max function returns the number with the highest value. It is flexible in the quantity of numbers that can be input at one time

1
var result = number.max(2, 5, 3, 45, 278.2, 1.2);

min( number x, number y, number z, ...)

The min function returns the number with the highest value. It is flexible in the quantity of numbers that can be input at one time

1
var result = number.min(127, 12, 98);

pow( number x, number y)

The pow function returns x to the power of y

1
var result = number.pow(2, 8);

**random()

The random function returns a random number between 0.0 and 1.0

1
var result = random();

randomInt( number min, number max )

The randomInt function returns an integer between min and max

1
var result = randomInt(0, 10);

randomFloat( number min, number max )

The randomFloat function returns a random floating point number between min and max

1
var result = randomFloat(7.5, 9.4);

sin( number x )

The sin function returns the sine of x (x is in radians)

1
var result = sin(0.34);

sinh( number x )

The sinh returns the hyperbolic sine of x

1
var result = sinh(0.97);

sqrt( number x )

The sqrt function returns the square root of x

1
var result = sqrt(100);

tan( number x )

The tan function returns the tangent of an angle

1
var result = tan(45);

tanh( number x )

The tanh function returns the hyperbolic tangent of x

1
var result = tanh(10);

trunc( number x )

The trunc function returns the integer part of x

1
var result = trunc(12.283);