java - How to determine if one number is within a certain range of another -
i determine if 1 number within range of number.
for instance, if have number 50, , input number i, able determine if i within 10 digits of 50. in other words, i in range of 40 49 or 51 60. how go doing that?
you can take absolute value of difference , check whether less 10, or can skip absolute value part , test whether difference between -10 , 10 (and not zero, if want exclude equality).
Comments
Post a Comment