aspose file tools
The moose likes Beginning Java and the fly likes summation oddity... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "summation oddity..." Watch "summation oddity..." New topic
Author

summation oddity...

Matt Horton
Ranch Hand

Joined: Feb 06, 2002
Posts: 107
Hello...
I am curious about the following behavior:

w/ x as double, the summation w/ g == 20 calculates to 3.547739...
w/ x as an int, the summation w/ g == 20 calculates to 1.0
What gives?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
If x is an integer, then 1/x is an integer division. It will be 0 for any x other than 1 or -1.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Matt Horton
Ranch Hand

Joined: Feb 06, 2002
Posts: 107
Thanks Ron!
 
 
subject: summation oddity...
 
Threads others viewed
"Drawing" Points on screen
label in coordinates
Simple Graph
standard deviation
board not Drawing...
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com