Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request : right and left shift operations #101

Open
PantalaLabs opened this issue Mar 24, 2023 · 4 comments
Open

Feature request : right and left shift operations #101

PantalaLabs opened this issue Mar 24, 2023 · 4 comments

Comments

@PantalaLabs
Copy link

PantalaLabs commented Mar 24, 2023

Thank you for your work! Great lib.

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

operations

@Blake-Madden
Copy link
Contributor

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

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

@PantalaLabs
Copy link
Author

Thank you a lot !

@Blake-Madden
Copy link
Contributor

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).

@PantalaLabs
Copy link
Author

Great ! Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants