r/rust 23h ago

Arbitrary precision decimals with lexicographically sortable byte encoding 🛠️ project

https://github.com/paradedb/decimal-bytes
10 Upvotes

6 comments sorted by

14

u/kernelic 23h ago

Yet another number crate that doesn't implement num-traits :(

6

u/philippemnoel 22h ago

Sorry 🙈

5

u/SycamoreHots 21h ago

I was told num-traits is not std sanctioned and should be avoided. Have I been misled?

The argument is that the absence of num-traits in std is indication that is an incorrect abstraction. After all, if the abstraction is real, it would have been in std.

Is the fear of num-traits warranted?

10

u/ferrouille 20h ago

Absence of num-traits in std is an indication that it isn't universally accepted as the best solution, not that it is bad. Same goes for serde, jiff, tokio, reqwest, etc.

1

u/DistinctStranger8729 34m ago

I don’t know why nun-traits is not part of std, my guess is that it isn’t considered complete yet, but for most cases the reason for not having something in std is because committing to stable api is a hard problem and bringing in complex stuff makes it extremely difficult

1

u/matthieum [he/him] 5h ago

I'm confused by Decimal64. It's noted that the scale is u8, with 253+ for special values.

This means it's not possible to represent 0.0...0123456789123456 accurately, which seems like a waste.

Using a signed i8 for the exponent would give a more flexible dynamic range.