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

log10 #397

Closed
probablykasper opened this issue Jun 9, 2021 · 3 comments · Fixed by #407
Closed

log10 #397

probablykasper opened this issue Jun 9, 2021 · 3 comments · Fixed by #407

Comments

@probablykasper
Copy link

Currently using decimal, but would love to switch to rust-decimal. The only thing (hopefully) preventing that is log10 support.

For reference, this is decNumber's log10 implementation: https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libdecnumber/decNumber.c#L1358-L1523

@jumbojets
Copy link

jumbojets commented Jun 10, 2021

If you can put up with an unoptimized solution, you could use the property log10(x) = ln(x) / ln(10) in the meantime until they implement an native solution. Perhaps it is by design that they don't have support for log10-- I don't know, as I am not affiliated with this project.

fn log10(x: Decimal) -> Decimal {
        x.ln() / dec!(10).ln()
}

Edit: unclear wording

@probablykasper
Copy link
Author

@jamesetaylor3 Ah cool, had no idea it works like that! Will try that out, thanks

@paupino
Copy link
Owner

paupino commented Jun 12, 2021

Hi both! log10 hasn't intentionally been left out of the library - it's just that it hasn't been implemented yet.
Some other solutions such as #389 would also benefit from this implementation. Consequently, I'll keep this ticket open as a feature request. We'll see if we can get an implementation of some sort in there within the next minor release or two.

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 a pull request may close this issue.

3 participants