How to check last digit of number

前端 未结 8 1909
情歌与酒
情歌与酒 2020-12-06 04:21

Is there a way to get the last digit of a number. I am trying to find variables that end with \"1\" like 1,11,21,31,41,etc..

If I use a text variable I can simply pu

8条回答
  •  醉梦人生
    2020-12-06 04:51

    I can't add a comment yet, but I wanted to iterate and expand on what Jim Garrison said

    Remainder when dividing by 10, as in numericVariable % 10

    This only works for positive numbers. -12%10 yields 8

    While modulus (%) is working as intended, throw on an absolute value to use the modulus in this situation.

    abs(numericVariable) % 10
    

提交回复
热议问题