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

change number representation #20

Open
speedy-lex opened this issue May 20, 2024 · 1 comment
Open

change number representation #20

speedy-lex opened this issue May 20, 2024 · 1 comment

Comments

@speedy-lex
Copy link

Represent numbers as *char but store the actual bits in the char

Currently numbers are being stored as strings (eg [‘1’, ‘2’, ‘3’]=123) which takes more time to do calculations with that to be storing it like this [0x1, 0x24] = 1*(16^2)+2*(16^1)+4*(16^0).

Why *char?

I suggest using char because it is exactly 8 bits on all machines so the code is (mostly) the same for 64 bit and 32 bit machines.

@avighnac
Copy link
Owner

Hey, this change makes sense, but I've pretty much completed this project ATP, and changing something so major would take a lot of time and effort.

Interestingly, I was also experimenting with larger bases (2^32 or 2^64, which I think would be even better, or 10^19)

Anyway, one of the reasons (not that this justifies the slower speeds, just thought I'd state this for the sake of it) I chose to go with base-10 is because it was the easiest to code and debug. Also, when read in base-10, the operations would be precise to the exact decimal place you want them to be (which, like, yay!)

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