WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Less than and Greater than Operator Problems


Question:

if newxcoord < newxcoord1 
xpin = xpin-15
message("%newxcoord% < %newxcoord1%","")
endif
for some reason, the values satisfy this if statement and the message shows, even though the "newxcoord" is equal to "newycoord1".

Answer:

Typical floating point math behaviour. You can almost never make two values match. Their ascii representation for display may be the same, but they could differ in the 0.000000000001 level which is beyond what is displayed, and thus they do not match.

The general rule in floating point math is to never expect two values to ever be exactly equal.

This example might demonstrate the interaction of float and integer math.

BoxOpen("","")
iLow  = 0
iHigh = 1000
For i=iLow To iHigh
   If !((100*i/iHigh) mod 10)
      Boxtext(i)
   EndIf
Next
BoxShut()
Exit

Article ID:   W16026
File Created: 2004:03:30:15:42:18
Last Updated: 2004:03:30:15:42:18