jite eghagha

Ranch Hand

Posts: 128

posted 9 years ago

I can't seem to get "multiplication" of a variable right!

Math.sqrt(variance / (HueArray.length-1) );

System.out.println("Variance: " + variance);

System.out.println("Deviation: " + variance*variance);

System.out.println("Deviation: " + Math.pow(variance,2) );

Results

Variance: 4.1351629998114355E7

Deviation: 1.709957303500951E15

Deviation: 1.709957303500951E15

clearly 4 * 4 is not 1.

Addition, and other things like that work fine with the same variable "variance".

Does anyone has a clue?

Math.sqrt(variance / (HueArray.length-1) );

System.out.println("Variance: " + variance);

System.out.println("Deviation: " + variance*variance);

System.out.println("Deviation: " + Math.pow(variance,2) );

Results

Variance: 4.1351629998114355E7

Deviation: 1.709957303500951E15

Deviation: 1.709957303500951E15

clearly 4 * 4 is not 1.

Addition, and other things like that work fine with the same variable "variance".

Does anyone has a clue?

posted 9 years ago

You're not multiplying 4 by 4, you're multiplying 40,000,000 by 40,000,000. The result is around 1,600,000,000,000,000.

If you inspect your numbers, you see they end with "E7" and "E15". This means, the number before that should be multiplied by 10^7 and 10^15 respectively.

If you inspect your numbers, you see they end with "E7" and "E15". This means, the number before that should be multiplied by 10^7 and 10^15 respectively.

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6

How To Ask Questions How To Answer Questions