multiplying DecimalFormat number (no longer rounded properly)

I'm basically trying to use DecimalFormat to get to two decimal places. I'm taking two integer values then dividing them and casting to a double I've put in sample values below. When I do as below I get a value that is no longer to two decimal places. It seems to be when multiply by the 3 it loses it's rounding.

DecimalFormat df = new DecimalFormat("#.00");
double d = Double.parseDouble(df.format((double)5/6))*3;

Can you let me know why this occurs and how to fix this?


In the statemet:

double d = Double.parseDouble(df.format((double)5/6))*3;

the formatting is not preserved (Double returns a double).

You could do, e.g.:


Need Your Help

Change Jenkins Port on MacOS

java macos continuous-integration port jenkins

I was wondering how one could change Jenkins' default port 8080. Using linux or windows, this is simply done with the configuration file. But the Mac config file of Jenkins looks completely different

OpenSSL not working on Windows, errors 0x02001003 0x2006D080 0x0E064002

php apache apache2 openssl easyphp

Problem: OpenSSL is not working in my Windows environment. OpenSSL repeatedly reports errors 0x02001003, 0x2006D080 and 0x0E064002.