B bobcpg Senior member Nov 14, 2001 951 0 0 Sep 21, 2004 #1 Programming in java and need to know how to format a double var to 2 decimal places. ie; x=3.256635 and i want x to equal 3.26 or 3.25 is ok too thanks -bob
Programming in java and need to know how to format a double var to 2 decimal places. ie; x=3.256635 and i want x to equal 3.26 or 3.25 is ok too thanks -bob
B bobcpg Senior member Nov 14, 2001 951 0 0 Sep 21, 2004 #2 Solved this one myself public static final double roundDouble(double d, int places) { return Math.round(d * Math.pow(10, (double) places)) / Math.pow(10,(double)places); }
Solved this one myself public static final double roundDouble(double d, int places) { return Math.round(d * Math.pow(10, (double) places)) / Math.pow(10,(double)places); }