No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Math Class
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.
mod(Integer, Integer)
Signature
public static Integer mod(Integer i1, Integer i2)
Return Value
Type: Integer
Example
1Integer remainder = math.mod(12, 2);
2system.assertEquals(remainder, 0);
3
4Integer remainder2 = math.mod(8, 3);
5system.assertEquals(remainder2, 2);random()
Signature
public static Double random()
Return Value
Type: Double
round(Double)
Signature
public static Integer round(Double d)
Parameters
- d
- Type: Double
Return Value
Type: Integer
round(Decimal)
Signature
public static Integer round(Decimal d)
Parameters
- d
- 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
1Decimal d1 = 4.5;
2Integer i1 = Math.round(d1);
3System.assertEquals(4, i1);
4
5Decimal d2 = 5.5;
6Integer i2 = Math.round(d2);
7System.assertEquals(6, i2);roundToLong(Decimal)
Signature
public static Long roundToLong(Decimal d)
Parameters
- d
- 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
1Decimal d1 = 4.5;
2Long i1 = Math.roundToLong(d1);
3System.assertEquals(4, i1);
4
5Decimal d2 = 5.5;
6Long i2 = Math.roundToLong(d2);
7System.assertEquals(6, i2);tanh(Decimal)
Signature
public static Decimal tanh(Decimal d)
Parameters
- d
- Type: Decimal
Return Value
Type: Decimal
tanh(Double)
Signature
public static Double tanh(Double d)
Parameters
- d
- Type: Double
Return Value
Type: Double