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
string | number | booleanThe value to be calculated.
Returns
numberThe 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
string | number | booleanThe number for which you want to determine the absolute value.
Returns
numberThe 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
string | number | booleanThe first number to be used for the summation.
string | number | booleanThe second number to be used for the summation.
Returns
numberThe 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
string | number | booleanThe first number to be used for the summation.
string | number | booleanThe second number to be used for the summation.
Returns
numberThe 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
string | number | booleanThe dividend.
string | number | booleanThe divisor.
Returns
numberThe 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
string | number | booleanThe dividend.
string | number | booleanThe divisor.
Returns
numberThe 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
string | number | booleanThe first factor.
string | number | booleanThe second factor.
Returns
numberThe 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
string | number | booleanThe first factor.
string | number | booleanThe second factor.
Returns
numberThe 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
string | number | booleanThe number a.
numbernumberThe rounding mode, see eMath.ROUND_*.
Returns
numberThe 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
string | number | booleanThe number a.
numberThe rounding mode, see eMath.ROUND_*.
Returns
numberThe 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
string | number | booleanThe minuend.
string | number | booleanThe subtrahend.
Returns
numberThe 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
string | number | booleanThe minuend.
string | number | booleanThe subtrahend.
Returns
numberThe difference resulting from the subtraction.
Throws
May throw an exception.
Example
result.string(eMath.subInt("14", "11"));
Throws
AditoUnsupportedOperationException
Properties
ROUND_CEILING
numberConstant 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
numberConstant for the rounding mode:
Rounds a number towards zero.
ROUND_FLOOR
numberConstant for the rounding mode:
Rounds a number towards negative infinity.
ROUND_HALF_DOWN
numberConstant 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
numberConstant 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
numberConstant 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
numberConstant 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.