Syntax
public static double truncate(Object aNumber, int precision) throws DtpIncompatibleFormatException public static double truncate(float aNumber, int precision) public static double truncate(double aNumber, int precision) public static int truncate(Object aNumber) throws DtpIncompatibleFormatException public static int truncate(float aNumber) public static int truncate(double aNumber)
Parameters
Return values
A double or int number.
Notes
This method removes digits from this number, starting from the right.
The first three forms of the methods truncate the number by removing the digits to the right of the decimal place, starting from the right. If the input number is an integer, it will not get truncated. The number of type Object must be either String, Double or Float.
The last three forms of the methods truncate the number by removing all digits to the right of the decimal and return the int value.
Examples
The following returns 123.45:
truncate("123.4567", 2);
The following returns 123:
truncate(123.456, 4)