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

Operating on BSON Decimal128 type #484

Closed
jvliwanag opened this issue Jul 19, 2024 · 2 comments
Closed

Operating on BSON Decimal128 type #484

jvliwanag opened this issue Jul 19, 2024 · 2 comments
Assignees
Labels

Comments

@jvliwanag
Copy link

Seeking guidance on how to operate on Decimal128 bson type such as value comparisons, additions, etc.

I noticed that bson-rust used decimal crate at one point but opted to make it internal. Is decimal byte compatible with Decimal128? Is it advisable to use from_raw_bytes to convert to Decimal?

@abr-egn
Copy link
Contributor

abr-egn commented Jul 19, 2024

The bson crate doesn't provide any manipulation for Decimal128 values beyond reading or printing strings. The binary representation is a standard IEEE 754-2008 value, so anything that uses that representation should work fine, including the decimal crate.

@abr-egn abr-egn closed this as completed Jul 19, 2024
@jvliwanag
Copy link
Author

Unfortunately found more details on RUST-960 that this won’t work. Haven’t found any crate that works yet. Looks like the only correct way right now is to convert to string and to reparse it on one of the rust decimal implementations. It won’t be performant though.

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

3 participants