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

Support representation of infinity #67

Open
thegedge opened this issue Aug 24, 2020 · 1 comment
Open

Support representation of infinity #67

thegedge opened this issue Aug 24, 2020 · 1 comment

Comments

@thegedge
Copy link

fn main() {
    println!("{:?}", str::parse::<f64>("inf"));
    println!("{:?}", str::parse::<f64>("+inf"));
    println!("{:?}", str::parse::<f64>("-inf"));
    
    println!("{:?}", str::parse::<f64>("inf").map(|v| v * 10.0));
    println!("{:?}", str::parse::<f64>("inf").map(|v| v * -10.0));
    println!("{:?}", str::parse::<f64>("inf").map(|v| v * 0.0));
}

Outputs

Ok(inf)
Ok(inf)
Ok(-inf)
Ok(inf)
Ok(-inf)
Ok(NaN)

This representation in f64 but not in BigDecimal resulted in a few issues being opened on nushell/nushell.

We were wondering if bigdecimal would be open to supporting the representation of Infinity and NaN?

@thegedge
Copy link
Author

#65 is a step in the right direction, giving us a way to at least avoid a panic. I still think it's possible to support these representations, but if this crate would prefer sticking with finite values, #65 works for us! 🙂

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

No branches or pull requests

1 participant