1. Avoiding if else by max of min:
e.g., if (x-CONST_1 < 0) y = CONST_2 else y = x-CONST_1
=> max(1,x-CONST_1)
condition CONST_2 > x-CONST_1
e.g., if (x+CONST_1 > CONST_3) y = CONST_4 else y = x+CONST_1
=> min(CONST_4,x+CONST_1)
condition CONST_4 < x+CONST_1
2.
No comments:
Post a Comment