Namespace
Math Fields
The following are fields for Math.
PI
Signature
public static final Double PI
Property Value
Type: Double
Math Methods
The following are methods for Math. All methods are static.
atan2(xCoordinate, yCoordinate)
Signature
public static Decimal atan2(Decimal xCoordinate, Decimal yCoordinate)
Return Value
Type: Decimal
atan2(xCoordinate, yCoordinate)
Signature
public static Double atan2(Double xCoordinate, Double yCoordinate)
Return Value
Type: Double
max(decimalValue1, decimalValue2)
Signature
public static Decimal max(Decimal decimalValue1, Decimal decimalValue2)
Return Value
Type: Decimal
Example
Decimal larger = math.max(12.3, 156.6);
Assert.areEqual(156.6, larger);
min(decimalValue1, decimalValue2)
Signature
public static Decimal min(Decimal decimalValue1, Decimal decimalValue2)
Return Value
Type: Decimal
Example
Decimal smaller = math.min(12.3, 156.6);
Assert.areEqual(12.3, smaller);
mod(integerValue1, integerValue2)
Signature
public static Integer mod(Integer integerValue1, Integer integerValue2)
Return Value
Type: Integer
Example
Integer remainder = math.mod(12, 2); Assert.areEqual(0, remainder); Integer remainder2 = math.mod(8, 3); Assert.areEqual(2, remainder2);
random()
Signature
public static Double random()
Return Value
Type: Double
round(doubleValue)
Signature
public static Integer round(Double doubleValue)
Parameters
-
doubleValue:
Type: Double
Return Value
Type: Integer
round(decimalValue)
Signature
public static Integer round(Decimal decimalValue)
Parameters
-
decimalValue:
Type: Decimal
Return Value
Type: Integer
Usage
Note that this rounding mode statistically minimizes cumulative error when applied repeatedly over a sequence of calculations.
Example
Decimal d1 = 4.5; Integer i1 = Math.round(d1); Assert.areEqual(4, i1); Decimal d2 = 5.5; Integer i2 = Math.round(d2); Assert.areEqual(6, i2);
roundToLong(decimalValue)
Signature
public static Long roundToLong(Decimal decimalValue)
Parameters
-
decimalValue:
Type: Decimal
Return Value
Type: Long
Usage
Note that this rounding mode statistically minimizes cumulative error when applied repeatedly over a sequence of calculations.
Example
Decimal d1 = 4.5; Long i1 = Math.roundToLong(d1); Assert.areEqual(4, i1); Decimal d2 = 5.5; Long i2 = Math.roundToLong(d2); Assert.areEqual(6, i2);
tanh(decimalAngle)
Signature
public static Decimal tanh(Decimal decimalAngle)
Parameters
-
decimalAngle:
Type: Decimal
Return Value
Type: Decimal
tanh(doubleAngle)
Signature
public static Double tanh(Double doubleAngle)
Parameters
-
doubleAngle:
Type: Double
Return Value
Type: Double