eric.dizon
30th January 2015, 18:39
I get compiler warning for the code below, I know I need to use double.cmp to prevent this but how do I utilized that if I am checking for < or > and not equality?

domain tcleng cxlog020.mten
domain tcleng cxlog020.mtst

if cxlog020.mtst > cxlog020.mten then

endif

vinceco252
30th January 2015, 18:46
These are the return values for double.cmp:

0 the difference between the doubles is less than the tolerance
-1 double1 is less than double2 (the difference is greater than the tolerance)
1 double1 is greater than double2 (the difference is greater than the tolerance)

so if double.cmp(cxlog020.mtst, cxlog020.mten, 0.0001) = 1 then
...

should be the equivalent of what you're looking for.

Vince

eric.dizon
30th January 2015, 19:46
Thanks vince, I had a brain fart at the moment didn't completely read the syntax :)

eric.dizon
30th January 2015, 19:59
I would assume the not equal statement should be ?

if not double.cmp(cxlog020.mtst, cxlog020.mten, 0.0001) = 1 then
...

vinceco252
30th January 2015, 20:08
No, if the double.cmp() function returns a 1, that means argument 1 is greater than argument 2.

Vince

eric.dizon
30th January 2015, 20:11
I was not clear with my question,
the statement I am trying to recreate is

if val1 <> val2 then
endif

is it the equivalent of the statement above?
if double.cmp(val1, val2,0.001) <> 0 then
endif

mark_h
2nd February 2015, 15:28
The format for double.cmp is double.cmp(double1, double2, double tolerance). So the return values are 0 which means the difference between the doubles is less than the tolerance (basically equal), -1 double1 is less than double2 or the difference is grate than the tolerance). Or 1 which means double1 is greater than double2. So if you want to know if they are now equal - yes use double.cmp() <>0.