aspose file tools*
The moose likes Beginning Java and the fly likes Strange result from double comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Strange result from double comparison" Watch "Strange result from double comparison" New topic
Author

Strange result from double comparison

Siamak Saarmann
Ranch Hand

Joined: Aug 21, 2004
Posts: 78
Hello,

I have a simple comparison of two double numbers. The same comparison when put in println function gives the correct response (see in the output) but the same comparison if assigned to a boolean value gives a wrong response;

I tried to compare numbers inside if condition, in a boolean variable, in reverse for (i.e: gone > MAX_MOVE) but every time it fails.

Could someone please tell me what is wrong?

I have narrowed down a bug in 20,000 lines of code to this and I can not figure out the reason.

Thank you.
Mac



PhD Artificial Intelligence, OCJP1.6
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,

i tried it is working...i do not find any issue..please can you explain clearly?

thanks & regards,
seetharaman
Siamak Saarmann
Ranch Hand

Joined: Aug 21, 2004
Posts: 78
I am not sure what is the problem. It works on my home PC, but as you see the output (printout of the variables) it did not work on my PC in university.

(gone<= MAX_MOVE) has given a different value in 2nd output line than the one coming from boolean variable.

I really don't know... This has happened for the first time in several years.
[ May 05, 2008: Message edited by: Siamak Saarmann ]
 
 
subject: Strange result from double comparison