• Post Reply Bookmark Topic Watch Topic
  • New Topic

error multiplying numbers  RSS feed

 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL, i see what you mean.

Thanks a lot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!