Check for integer

YoDougYoDoug 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?

Comments

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





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


    I think I get that @DenisFR.  Nice



    Lee Justice
  • YoDougYoDoug 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!
  • MickyMicky 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
Sign In or Register to comment.