Check for integer

I have a situation where I need to check to see if a calculated num value is an integer. I am struggling to find an easy way to do this. Suggestions?

Hello,

bIsInt:=(Trunc(numValue)=numValue);

Try NumToStr, then StrMatch for a “.”, the decimal.

Nice simple code! I knew there would be an easy way to do it. Thanks!

Hello,

RAPID offers the instruction “TryInt” to check if a number is an integer.


VAR num myint := 5.2;

**TryInt** myint;

ERROR

IF ERRNO = ERR_INT_NOTVAL THEN

  myint := Round(myint);

  RETRY;

ENDIF

/BR
Micky