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

Add support for Unary Minus and Unary Plus #50

Open
NeeEoo opened this issue Mar 13, 2021 · 5 comments
Open

Add support for Unary Minus and Unary Plus #50

NeeEoo opened this issue Mar 13, 2021 · 5 comments

Comments

@NeeEoo
Copy link
Contributor

NeeEoo commented Mar 13, 2021

Unary Plus is unneeded since it does nothing. Defined as +NUM
Unary Minus is defined as -NUM
They should not break BINOP.

@elikaski
Copy link
Owner

We don't have signed numbers

@NeeEoo
Copy link
Contributor Author

NeeEoo commented Mar 14, 2021

Yea but it still might help to check if the number is negative such as -1. Currently you would do 0-1

@elikaski
Copy link
Owner

0-1 is 255
It is possible to support unary minus sign syntax-wise, but then we would have (-1 == 255) evaluate to true and so on
I don't know if it's a desired behavior... What do you think?

@NeeEoo
Copy link
Contributor Author

NeeEoo commented Mar 14, 2021

The resulting bf code would be [-]- since the compiler shouldn't assume the cell size.
If i did 5-6 it would become -1. If it automatically set it to 255 and if the interpreter was 16-bit cells the check would fail.

@NeeEoo
Copy link
Contributor Author

NeeEoo commented Mar 15, 2021

It would still be that 0-1 == 255. But for 16-bit interpreters it would be 0-1 == 65535

The compiler shouldn't convert -1 to the literal 255. It should use wrapping.

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