# Check for integer

United States
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?

• FRANCE ✭✭✭
Hello,
`:=(Trunc(`<code>numValue`)=`<code>numValue`);<code>bIsInt`

• United States ✭✭✭
Try NumToStr, then StrMatch for a ".", the decimal.
Lee Justice
• United States ✭✭✭
DenisFR said:
Hello,
`:=(Trunc(`<code>numValue`)=`<code>numValue`);<code>bIsInt`

I think I get that @DenisFR.  Nice

Lee Justice
• United States
DenisFR said:
Hello,
`:=(Trunc(`<code>numValue`)=`<code>numValue`);<code>bIsInt`

Nice simple code! I knew there would be an easy way to do it. Thanks!
• Germany ✭✭✭
edited July 2019
Hello,

RAPID offers the instruction "TryInt" to check if a number is an integer.
`<p>VAR num myint := 5.2;</p><p><br></p><p><b>TryInt</b> myint;<br></p><p>ERROR<br></p><div><p>IF ERRNO = ERR_INT_NOTVAL THEN</p><p><br></p><p>  myint := Round(myint);</p><p><br></p><p>  RETRY;</p><p><br></p></div><div><p><span>ENDIF<br></span></p></div>`
/BR
Micky