2021-05-01, 07:09 PM
2021-04-29: IS_IN_RANGE
If you have some code like this:
Or the much better:
You can now use YSI to do it an even better way:
This checks that the first parameter is AT LEAST the second parameter, and SMALLER than the third parameter, and is faster than the other two methods. If you want to change the ranges, add or subtract 1. For example to check if something is a numeric character do:
That will do:
Or more strictly it will do:
These being integers, those are the same (they aren?t for floats).
If you have some code like this:
Quote:
if (a >= 0 && a < 10)
Or the much better:
Quote:
if (0 <= a < 10)
You can now use YSI to do it an even better way:
Quote:
if (IS_IN_RANGE(a, 0, 10))
This checks that the first parameter is AT LEAST the second parameter, and SMALLER than the third parameter, and is faster than the other two methods. If you want to change the ranges, add or subtract 1. For example to check if something is a numeric character do:
Quote:
if (IS_IN_RANGE(character, '0', '9' 1))
That will do:
Quote:
if ('0' <= character <= '9')
Or more strictly it will do:
Quote:
if ('0' <= character < '9' 1)
These being integers, those are the same (they aren?t for floats).