android - Rounding errors in Java -
i'm having rounding issues in java (i.e. whole = 1387.583515625 output x = 5836 instead of 5835. have searched issue before , i've tried various of answers still can't seem yo work. ideas?
decimalformat df = new decimalformat(".####"); df.setroundingmode(roundingmode.ceiling); int x = integer.parseint(string.format(df.format(whole)).split("\\.")[1]);
look @ table decide want https://docs.oracle.com/javase/7/docs/api/java/math/roundingmode.html
df.setroundingmode(roundingmode.half_up);
Comments
Post a Comment