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

Binary number support #87

Closed
xvxx opened this issue May 9, 2019 · 4 comments
Closed

Binary number support #87

xvxx opened this issue May 9, 2019 · 4 comments
Labels
good first issue Good for newcomers wontfix This will not be worked on

Comments

@xvxx
Copy link
Collaborator

xvxx commented May 9, 2019

It would be nice if LDPL could work with binary data. It would probably need two things:

  1. Support for binary (0b1010) and hex (0xFF) number literals.
  2. Support for bit operations.

Maybe the commands could look like this:

  • BITWISE A AND B IN C
  • BITWISE A OR B IN C
  • BITWISE A XOR B IN C
  • BITWISE NOT A IN C
  • BITWISE SHIFT A LEFT BY B IN C
  • BITWISE SHIFT A RIGHT BY B IN C
  • GET BIT AT N FROM A IN C

Would this be a good candidate for the language or should it be an extension?

@Lartu
Copy link
Owner

Lartu commented May 10, 2019

I think this would be a great addition to the language! We can even add the symbols <, >, |, &, ¬ to represent shift left, right, or, and and not to solve math without changing almost anything of the current code!

@xvxx
Copy link
Collaborator Author

xvxx commented May 10, 2019

I think solve math will take some work because C/C++ doesn't allow bitwise on floating point numbers.

So for the normal statements, we probably have to: 1. check if there's a fraction, 2. convert to int if no fraction (error if so), 3. perform bitwise operation, 4. convert back to float. This is how Lua does it according to manual section 3.4.3, since Lua also only has a single number type as far as the programmer is concerned.

However, if we add a sibling to solve math and name it something like solve bitwise, we can convert all input to int first. So maybe something like: IN var SOLVE BIT a | b

@Lartu
Copy link
Owner

Lartu commented May 10, 2019

Oh right, we are using floating point numbers... I didn't think about that. I like what you are saying though. There's no real need to add it to solve math so don't really mind that.

@Lartu Lartu added feature request Please add this to the language! good first issue Good for newcomers wontfix This will not be worked on and removed feature request Please add this to the language! labels Jun 17, 2019
@Lartu
Copy link
Owner

Lartu commented Jun 26, 2019

@dvkt should I close this? I don't really think that we'll end up using this in LDPL an in any case we could implement it as part of the standard library.

@Lartu Lartu closed this as completed Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants