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

FluentValue::into_number may cause issues with decimal conversions #92

Closed
kazimuth opened this issue Feb 25, 2019 · 1 comment
Closed
Labels
crate:fluent-bundle Issues related to fluent-bundle crate design-decision Issues pending design decision, usually Rust specific duplicate enhancement help wanted We need help making decisions or writing PRs for this.

Comments

@kazimuth
Copy link
Contributor

impl FluentValue {
    pub fn into_number<S: ToString>(v: S) -> Result<Self, ParseFloatError> {
        f64::from_str(&v.to_string()).map(|_| FluentValue::Number(v.to_string()))
    }
    // ...
}

https://github.com/projectfluent/fluent-rs/blob/master/fluent-bundle/src/types.rs#L32

f64 has limited precision which may not accurately represent an input number, for instance if I'm using a d128 to represent currency.

It might be worth writing a custom parser that validates inputs are usable numbers without modifying them.

@zbraniecki zbraniecki added design-decision Issues pending design decision, usually Rust specific enhancement crate:fluent-bundle Issues related to fluent-bundle crate help wanted We need help making decisions or writing PRs for this. labels Apr 17, 2019
@alerque
Copy link
Collaborator

alerque commented May 6, 2024

This issue is a duplicate of #337 (and also #214). That issue is of course later than this one, but since it has some suggestions of a fix I think I'll close this version no discussion continues elsewhere. I would suggest subscribing to #337 if you want to be notified when this is fixed.

@alerque alerque closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate:fluent-bundle Issues related to fluent-bundle crate design-decision Issues pending design decision, usually Rust specific duplicate enhancement help wanted We need help making decisions or writing PRs for this.
Projects
None yet
Development

No branches or pull requests

3 participants