This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes program gives different results with same data Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "program gives different results with same data" Watch "program gives different results with same data" New topic
Author

program gives different results with same data

amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
I make program which do some manipulation on data from dataase and return a double value. It works fine there is no error .Problem is that with same data it gives different output .I can't understand it because logic is same ,data is same then why it produce different result .In my program i do calculation on double and then add all the previous double .I also use Double object .Is changing from string to Double object or double and adding all this figures will it give me different result.Is using d.doubleValue gives different result .
Thanks
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Could be a phase of the moon issue.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
if its floating point it oculd be a rounding error, try using strictfp/StrictMath
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16487
    
    2

If you add the same floating-point numbers in different orders, it's possible to get different answers. But they normally won't be significantly different, unless the numbers vary considerably in size.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
Does your program use multiple threads at all? Behavior such as you describe is often a sign of problems with threading.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: program gives different results with same data
 
Similar Threads
newInstance() method
Acces table
wrong value
How to dynamically cast an Object ?
Value changed after casting from float to double?