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

Big Numbers for Constants #2

Closed
gingerBill opened this issue Dec 4, 2016 · 4 comments
Closed

Big Numbers for Constants #2

gingerBill opened this issue Dec 4, 2016 · 4 comments

Comments

@gingerBill
Copy link
Member

In this language, I want constants to work very similar to how they work in Go. This requires the need for a big numbers library as it needs arbitrary precision for numbers to behaviour as numbers.

NUM_A :: 1<<100;
NUM_B :: NUM_A>>90;

Should be valid and result in NUM_B == 1<<10.

Blog article on how Go constants work: https://blog.golang.org/constants

@ratchetfreak
Copy link

ratchetfreak commented Dec 5, 2016

BigNum as a language feature is going to need RAII semantics (destructors and copy/move semantics). As just about all standard implementations will allocate auxiliary memory that needs to be cleaned up.

Though if you just want something that works for compile-time constant folding then something like gmp (licenced under LGPL v3) would work. It does both integer and floating point math.

@gingerBill
Copy link
Member Author

Sorry for the confusion but I do not want this to be a run time feature but rather a compile time feature for the constant system. I want numbers to just work as number.

gmp might be a good option so I might have to consider it.

@Kelimion
Copy link
Member

http://www.libtom.net/LibTomMath/ is also a good alternative. Dual licensed as public domain / WTFPL.

@gingerBill
Copy link
Member Author

This has been implemented with the new custom BigInt library. As the name suggests, only integers are supported, no BigFloat yet.

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

No branches or pull requests

3 participants