stencillogic / num-bigfloat Goto Github PK
View Code? Open in Web Editor NEWIncreased precision floating point numbers implemented purely in Rust.
License: MIT License
Increased precision floating point numbers implemented purely in Rust.
License: MIT License
While using the num-bigloat
crate, we were hitting a panic
mentioning that thread 'main' panicked at 'attempt to add with overflow'
After some investigation, we noticed that any operation that results in a value where the result is -1 > x < 1
, panics.
For example, the code snippet below results in a panic.
use num_bigfloat::BigFloat;
fn main() {
let x = BigFloat::from(1);
let y = BigFloat::from(2);
let z = x / y;
println!("{z:?}");
}
assert!(BigFloat::from(-1).frac() == BigFloat::from(0))
is not equal to true
-0 is not equal to 0
Is this a bug?
some code for debugging
let a = BigFloat::from(-1).frac();
let b = BigFloat::from(0);
assert!(a==b);
Could num-traits be implemented for BigFloat
with the use of a feature flag? This would make it useable for libraries that depend on it.
The epsilon's mantissa is backwards making the epsilon value useless.
In the following situation:
println!("input: {}", input);
let val = match BigFloat::parse(input) {
Some(s) => s,
None => return None,
};
println!("val: {}", val.to_string());
The following are being treated as though they are identical:
input: 100000000000000000000000000000000000000000000.00000000000000000000000000000000000000001
val: 1.000000000000000000000000000000000000000e+39
input: 100000000000000000000000000000000000000000000.00000000000000000000000000000000000000002
val: 1.000000000000000000000000000000000000000e+39
When I compare them using .cmp() it returns 0.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.