-
Notifications
You must be signed in to change notification settings - Fork 186
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
Version 2 Roadmap planning #354
Comments
Brainstorming thread: Lazily evaluated rational numbers? i.e. maintain precision until absolutely necessary. Could be a different type using decimal as a subset. |
Sorry to bother you. |
Hi @zzhengzhuo - sorry for the delay in reply. Truth be told I haven't had much time to focus on this project (or others for that matter) as of late. But I do agree that we could probably, at the very least, start a branch revisiting the API/Errors and cleaning that up. From there we could really just focus on the internals (if need be). |
Thanks for your response. I'll be starting development on the master branch soon. I'll likely begin with feature #310, as it seems to involve significant breaking changes. |
I don't have a firm list however you're right that #310 is biting off quite a large chunk (hence why it was to investigate). If I were to think of a simple path to v2 I'd probably begin with:
I think for underlying storage it could be interesting to play around with 128 bit types. At the time, I didn't notice much difference, or it was slower, on the machines I tested on. That said, recent improvements with 128 bit handling could be interesting. Though, this is perhaps another investigation rather than a "go do". While I'd be interested in playing around with const generics it really is likely a complete rewrite - or at least touching almost every part of the code. So I think an investigation/prototype and documentating what needs to change / could change is worthwhile as a first step. |
Based on my preliminary investigation, if pub struct Decimal<const LIMBS: usize> {
flags: u32,
limbs: [u32; LIMBS],
} then const generics would be a variation of the current version, making modifications relatively simple.
Next comes the more tedious part of removing deprecated methods and so on. In addition, there are a few other aspects that need to be concluded:
What do you think? @paupino |
I think the complexity will creep in once you get to the multiplication / division logic. There are some optimizations in there that assume a fixed size array right now. In fact, there is some "short circuit" optimizations that rely on the structure of hi/lo/mid with relevant overflow. For example, multiplication allocates space for a 192 bit number and then tries to resize it back into a 96 bit number. If you have a variable size number you'd need to be able to handle all of this more dynamically. Anyway - not meaning to discourage you - more so to take a deeper look a these particular areas of code. These are the more complex components that would need rewriting which to be honest, is what has stopped me each time. After doing so, it should be fairly easy to benchmark that the behavior of |
Hi, @paupino, thank you a lot for building this! I'm using this crate in iceberg-rust, the Rust implementation of Apache Iceberg™. I love this crate, but I've noticed a gap: Iceberg specifies decimal support up to 38 precision, while this crate only supports 28. Is it possible to extend our decimal support range? For example, could we use 128 bits to store the value? I'm willing to help implement this part. |
Some thoughts for version 2 of the Decimal library. Issue numbers will be added as they are created.
deprecated
functions/features.std
is only required by default IF it is required.u128
optimizations when performing 96 bit operations. The hypothesis is that I can squeeze further performance from more complex numbers. Related to i128/u128 based implementation #135.From
support forDecimal
. Decimal::from((u128|i128)::MAX) panics at runtime,TryFrom
looks like the only reasonable approach. (excerpt: "Note: This trait must not fail. The From trait is intended for perfect conversions. If the conversion can fail or is not perfect, use TryFrom").The text was updated successfully, but these errors were encountered: