• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error multiplying numbers

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL, i see what you mean.

Thanks a lot.
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic