Skip to main content
Version: 2025.2

eMath

Mathematische Funktionen für JDito. Hier ist eine richtige Berechnung sichergestellt.

cp rl

Methods​

absDec​

absDec(pA): number

eturns the absolute value of the string you passed. (For decimal numbers.)

Parameters​

pA
string | number | boolean

The value to be calculated.

Returns​

number

The amount of a.

Throws​

AditoUnsupportedOperationException

Example​

var number = "-25.3";
var absolute = eMath.absDec(number);
question.showMessage(absolute);

Throws​

May throw an exception.


absInt​

absInt(pA): number

Returns the absolute value of the string you passed. (For integers.)

Parameters​

pA
string | number | boolean

The number for which you want to determine the absolute value.

Returns​

number

The amount of a.

Throws​

May throw an exception.

Example​

var number = "-25";
var absolute = eMath.absInt(number);
question.showMessage(absolute);

Throws​

AditoUnsupportedOperationException


addDec​

addDec(pA, pB): number

Adds two decimal numbers.

Parameters​

pA
string | number | boolean

The first number to be used for the summation.

pB
string | number | boolean

The second number to be used for the summation.

Returns​

number

The sum.

Throws​

AditoUnsupportedOperationException

Example​

result.string(eMath.addDec("1.45", "1.35"));

Throws​

May throw an exception.


addInt​

addInt(pA, pB): number

Adds two integers.

Parameters​

pA
string | number | boolean

The first number to be used for the summation.

pB
string | number | boolean

The second number to be used for the summation.

Returns​

number

The sum.

Throws​

May throw an exception.

Example​

result.string(eMath.addInt("13", "5"));

Throws​

AditoUnsupportedOperationException


divDec​

divDec(pA, pB): number

Divides b by a. (For decimal numbers.)

Parameters​

pA
string | number | boolean

The dividend.

pB
string | number | boolean

The divisor.

Returns​

number

The result of the division.

Throws​

AditoUnsupportedOperationException

Example​

result.string(eMath.divDec("1.45", "1.35"));

Throws​

May throw an exception.


divInt​

divInt(pA, pB): number

Divides b by a. (For integers.)

Parameters​

pA
string | number | boolean

The dividend.

pB
string | number | boolean

The divisor.

Returns​

number

The result of the division.

Throws​

May throw an exception.

Example​

result.string(eMath.divInt("16", "5"));

Throws​

AditoUnsupportedOperationException


mulDec​

mulDec(pA, pB): number

Multiplies a by b. (For decimal numbers.)

Parameters​

pA
string | number | boolean

The first factor.

pB
string | number | boolean

The second factor.

Returns​

number

The product of the multiplication.

Throws​

AditoUnsupportedOperationException

Example​

result.string(eMath.mulDec("1.45", "1.35"));

Throws​

May throw an exception.


mulInt​

mulInt(pA, pB): number

Multiplies a by b. (For integers.)

Parameters​

pA
string | number | boolean

The first factor.

pB
string | number | boolean

The second factor.

Returns​

number

The product of the multiplication.

Throws​

May throw an exception.

Example​

result.string(eMath.mulInt("17", "18"));

Throws​

AditoUnsupportedOperationException


roundDec​

roundDec(pA, pScale, pRoundingMode): number

Rounds a as a decimal number.

Parameters​

pA
string | number | boolean

The number a.

pScale
number
pRoundingMode
number

The rounding mode, see eMath.ROUND_*.

Returns​

number

The rounded value.

Throws​

May throw an exception.


Example​

var x = eMath.roundDec("1.45", 1, eMath.ROUND_HALF_UP);
question.showMessage(x);

roundInt​

roundInt(pA, pRoundingMode): number

Rounds a as an integer.

Parameters​

pA
string | number | boolean

The number a.

pRoundingMode
number

The rounding mode, see eMath.ROUND_*.

Returns​

number

The rounded value.

Throws​

May throw an exception.


Example​

result.string(eMath.roundInt("12"));

subDec​

subDec(pA, pB): number

Subtracts b from a. (For decimal numbers.)

Parameters​

pA
string | number | boolean

The minuend.

pB
string | number | boolean

The subtrahend.

Returns​

number

The difference resulting from the subtraction

Throws​

AditoUnsupportedOperationException

Example​

result.string(eMath.subDec("1.45", "1.35"));

Throws​

May throw an exception.


subInt​

subInt(pA, pB): number

Subtracts b from a. (For integers.)

Parameters​

pA
string | number | boolean

The minuend.

pB
string | number | boolean

The subtrahend.

Returns​

number

The difference resulting from the subtraction.

Throws​

May throw an exception.

Example​

result.string(eMath.subInt("14", "11"));

Throws​

AditoUnsupportedOperationException

Properties​

ROUND_CEILING​

number

Constant for the rounding mode:

Rounds a number towards positive infinity. If the decimal number is positive, the behavior is the same as for ROUND_UP, if it is negative, it is the same as ROUND_DOWN.

The value is never reduced.


ROUND_DOWN​

number

Constant for the rounding mode:

Rounds a number towards zero.


ROUND_FLOOR​

number

Constant for the rounding mode:

Rounds a number towards negative infinity.


ROUND_HALF_DOWN​

number

Constant for the rounding mode:

The number is rounded towards the "next neighbor", except if both are equidistant. In this case, it is rounded towards zero.


ROUND_HALF_EVEN​

number

Constant for the rounding mode:

The number is rounded towards the "next neighbor", except if both are equidistant. In this case, it is rounded towards the even neighbor.


ROUND_HALF_UP​

number

Constant for the rounding mode:

The number is rounded towards the "next neighbor", except if both are equidistant.

In this case, it is rounded towards up (opposite direction from zero).


ROUND_UP​

number

Constant for the rounding mode:

Rounds a number up. The digit before the discarded digit is always rounded up (unequal to zero).

This rounding mode will never decrease the value of the digit rounded.