The 2 does need to be fixed. T is only and exactly 1.
Piecewise functions aren’t necessary. Let’s not use those.
First hint:
For each operator, there are essentially 2 different problems with 2 separate solutions. One is for integer arithmetic and one is for real number arithmetic. (In some simpler cases like for “and” there won’t be a difference.)