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

Proposal: Arbitrary Precision Numbers #72

Open
vihanb opened this issue Aug 6, 2016 · 3 comments
Open

Proposal: Arbitrary Precision Numbers #72

vihanb opened this issue Aug 6, 2016 · 3 comments
Labels

Comments

@vihanb
Copy link
Member

vihanb commented Aug 6, 2016

This proposal details the workings of the planned upgrade to arbitrary precision numbers. Details are yet to be worked out

Overview

At the moment Cheddar has limited 64-bit numbers. These can loose precision with large numbers and also have floating point errors. This is not at all wanted in Cheddar and therefore, after a certain limit has been reached, should be implicitly upgraded to "bigints".

Definition

Using Number.MAX_SAFE_INT to detail the largest integer than can be reached. Use an alternative CheddarNumber#big_value to store an array detailing the number. The array should be a Uint32Array typed arrays allocated to the size of the number, where each item is exactly 32-bits. With each item representing a 32-bit uint (4294967295). CheddarNumber#bigsize stores the number of allocated sections in the array which will be referenced by each operation to determine whether or not the number has been promoted. During any operation if the Number.MAX_SAFE_INT has been exceeded, the promotion will occur if and only if, the number stores a CheddarClass#Reference to a variable or, the number has lost precision. This is too avoid needlessly promoting where the final value is near Number.MAX_SAFE_INT but still has precision.

Changelist

The following needs to be changed:

  • CheddarNumber#value getters and setters
  • CheddarNumber.Operator promotion

and probably some more stuff...

@schas002
Copy link

'cuz there weren't enough tag events 😜

@schas002
Copy link

But seriously, I give a +1.

@vihanb
Copy link
Member Author

vihanb commented Dec 27, 2016

Okay, so I'll be implementing this in C++ forked off cheddar-lang/Cheddar (2f52151). However platform-independent code gets more difficult to product due to the wide amount of different platforms that need to be supported. Particularity since Windows does not like to play nice with like... everything else. Anyway, I can greatly accelerate all work on this if anyone would like to volunteer to help me test on Windows.

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

No branches or pull requests

2 participants