List of utility methods to do Double Number Truncate
double | truncate(double oldVal, double newMin, double newMax) truncate double retVal = oldVal; if (retVal < newMin) { retVal = newMin; if (retVal > newMax) { retVal = newMax; return retVal; ... |
double | truncate(double value, double precision) Utility method used to truncate a double to the given precision. double result; precision = Math.pow(10, precision); if (value > 0) { result = Math.floor(value * precision) / precision; } else { result = Math.ceil(value * precision) / precision; return result; ... |
double | truncate(double value, int precision) truncate String str = Double.toString(value); String precisionstr = str.substring(str.indexOf('.') + 1); if (precisionstr.length() <= precision) { return value; } else { long tmp = Math.round(value * Math.pow(10, precisionstr.length())); for (int i = 0; i < precisionstr.length() - precision - 1; i++) { tmp /= 10; ... |
double | truncate(double value, int truncation) truncate return Math.floor(value * truncation) / truncation;
|
int | truncate(double x) truncate int res; if (x > 255) res = 255; else if (x < 0) res = 0; else res = (int) x; return res; ... |
double | truncate(double x) Returns the value of the integer of highest magnitude (farthest from zero) whose absolute value is at most that of x .
return x > 0.0 ? Math.floor(x) : Math.ceil(x);
|
double | truncate(double x, double gran) truncate return Math.round(x / gran) * gran;
|
double[] | truncate(double[] arr, int m) truncate double[] tArr = new double[m]; System.arraycopy(arr, 0, tArr, 0, m); return tArr; |
double | truncate(final double value, final double min, final double max) truncate return Math.min(Math.max(value, min), max);
|
double | truncate(final double value, final double precision) Truncate a value to the specified precision. double f, v; boolean b; if (precision <= 0.0d) return value; if (value == 0.0d) return 0.0d; if (value < 0.0d) { v = -value; ... |