double division errors

why does this code:

double x = 0.1;

double y = 17.7299;

double z = (x * y);

Java says the value ofz is1.8639.

of course, the correct answer is1.7729

now, what is going on?

[337 byte] By [dew2hirooa] at [2007-11-27 6:54:11]
# 1

What are you talking about?

double x = 0.1;

double y = 17.7299;

double z = (x * y);

System.out.println("x: " + x);

System.out.println("y: " + y);

System.out.println("z: " + z);

results:

x: 0.1

y: 17.7299

z: 1.77299

TuringPesta at 2007-7-12 18:29:05 > top of Java-index,Java Essentials,New To Java...
# 2

It does it for me too.

double x = 0.1;

double y = 17.7299;

double z = (x * y);

System.out.println("x: "+x);

System.out.println("y: "+y);

System.out.println("z: 1.8639");

plz fix teh codez 4me...

CaptainMorgan08a at 2007-7-12 18:29:05 > top of Java-index,Java Essentials,New To Java...
# 3
Where's the division? :P
nogoodatcodinga at 2007-7-12 18:29:05 > top of Java-index,Java Essentials,New To Java...
# 4
> It does it for me too.System.out.println("z: 1.8639");One moment I was so d@mned confusedand the next, I was laughing hysterically, lol!
TuringPesta at 2007-7-12 18:29:05 > top of Java-index,Java Essentials,New To Java...
# 5
forget it.i shouldn't code on friday nite.
dew2hirooa at 2007-7-12 18:29:05 > top of Java-index,Java Essentials,New To Java...
# 6

> It does it for me too.

>

> double x = 0.1;

> double y = 17.7299;

> double z = (x * y);

>

> System.out.println("x: "+x);

> System.out.println("y: "+y);

> System.out.println("z: 1.8639");

>

> plz fix teh codez 4me...

Nothing a gold old RegEx can't fix:

System.out.println("z: 1.8639".replaceAll("\\d*\\.\\d*", String.valueOf(z)));

prometheuzza at 2007-7-12 18:29:05 > top of Java-index,Java Essentials,New To Java...