tinyexpr icon indicating copy to clipboard operation
tinyexpr copied to clipboard

Feature request : right and left shift operations

Open PantalaLabs opened this issue 1 year ago • 4 comments

Thank you for your work! Great lib.

a >> 1 //right shift
b << 3 //left shift

operations

PantalaLabs avatar Mar 24 '23 17:03 PantalaLabs

In case this helps, I've added support for these operators to the C++ version at:

https://github.com/Blake-Madden/tinyexpr-plusplus

Blake-Madden avatar May 25 '23 23:05 Blake-Madden

Thank you a lot !

PantalaLabs avatar May 29 '23 21:05 PantalaLabs

I also just added the functions BITLSHIFT() and BITRSHIFT(), which work like their counterparts in Excel. Note that if you pass a negative shift amount to BITLSHIFT(), then it calls BITRSHIFT() and vice-versa. A strange design, but that's what Excel does.

The << and >> operators have a very low operator precedence, but I emulate what C compilers do. I recommend wrapping those expressions in parentheses (as does the MSVC compiler).

Blake-Madden avatar May 29 '23 22:05 Blake-Madden

Great ! Thank you!!

PantalaLabs avatar May 30 '23 01:05 PantalaLabs