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

Use coef: i128 in decimal #1017

Merged
merged 4 commits into from
Nov 15, 2024
Merged

Use coef: i128 in decimal #1017

merged 4 commits into from
Nov 15, 2024

Conversation

billylanchantin
Copy link
Contributor

Changes our ExDecimal representation to:

pub struct ExDecimal {
    pub sign: i8,
    pub coef: i128, // was u64
    pub exp: i64,
}

This gives us the ability to represent larger decimals. The trade-off is we could technically create an invalid ExDecimal in our Rust code. But I don't think it's a practical concern: we just need to be careful to always call .abs() when we instantiate it.

Before we were using `coef: u64` as that was the
largest type that was also guarunteed to be
positive. This left half the bits unused, however.
This change makes it so we're using all available
bits. Even though technically we could make an
invalid ExDecimal after this change, it's not a
practical concern.
This reverts an old change that was a work around
for the `coef: u64` thing.
@billylanchantin billylanchantin merged commit c07ec04 into main Nov 15, 2024
4 checks passed
@billylanchantin billylanchantin deleted the bl-use-i128-in-decimal branch November 15, 2024 00:04
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

Successfully merging this pull request may close these issues.

2 participants