List of utility methods to do Double Number Truncate
long | trunc(double value) Truncates the specified value. return (long) value; |
double | trunc(double value, double threshold) trunc return Math.max(Math.min(value, threshold), -threshold);
|
double | trunc(double value, int dp) Truncates a double to given decimal digits double factor; factor = Math.pow(10, dp); return Math.floor(value * factor) / factor; |
double | trunc(double value, int len) trunc if (Double.isNaN(value)) { return Double.NaN; if (Double.isInfinite(value)) { return value; double p = Math.pow(10, len); if (value > 0) { ... |
double | trunc(double x) Return the integer portion of a double as a double. long lx = (long) x; return (double) lx; |
double | trunc(double x) trunc return x - x % 1;
|
double | trunc(double x, double y) Truncate x down to the nearest y. return y * Math.floor((x + .00001) / y);
|
double | trunc4(Double number) trunc return Math.round(number * Math.pow(10, 4)) / Math.pow(10, 4);
|
double | truncate(double d) truncate if (d < 0) return -1 * Math.floor(d * -1); else return Math.floor(d); |
double | truncate(double fullVal, int digits) Given a double, zeros all portions of the fraction past a given number of digits. double factor = Math.pow(10.0, (double) digits); int itmp = (int) (factor * fullVal); return ((double) itmp) / factor; |