This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
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.
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: 18541
    
    8

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: 18671
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://aspose.com/file-tools
 
subject: program gives different results with same data
 
Similar Threads
How to dynamically cast an Object ?
wrong value
Acces table
newInstance() method
Value changed after casting from float to double?