Perform "In range-logic" check purely with calculations

24 Views Asked by At

I don't really know how to explain this well in mathematical terms, but some simple programming code logic can be rewritten in math instructions:

E.g.

If (number is even):
  perform addition with number 3
else:
  perform substraction with number 3

Can be rewritten to:

+ ( 3 * (-1 ^ number)) 

-> if number is even a multiplying with one will happen, if not, a multiplying with -1 will happen.

I was wondering if you could make a "numeric" equivalent of the following logic (Without making use of "smaller than" logic?):

if (10<number<20 or 60<number<80):
   perform addition with number zero
else:
   perform addition with number ten

I've tried to find it myself, but didn't really come up with something. Most of my attempts involved using the "modulo" devision, to try to check if number is in range, but that didn't bring me much further.