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?
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?
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
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...
> 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)));