Comments (15)
Just a fyi: I found a case that may need to use wrapping:
use libm::F64Ext; // adds methods to `f64`
pub fn sqrt(x: f64) -> f64 {
x.sqrt()
}
Calling sqrt(2.0) in debug mode gives me: (using git master branch Oct 31, 2018)
thread 'math1' panicked at 'attempt to add with overflow', /home/mswanson/.cargo/git/checkouts/libm-62d0d08057355aaa/3559e70/src/math/sqrt.rs:180:18
from libm.
I've done some work on this. It's not very principled at the moment, I just ran the tests on debug mode.
I'm investigating fuzzing to see if I can get better coverage.
Link: issue-4
from libm.
Just want to note that this is not needed to get math support in wasm / core because the math functions will be compiled in release mode. It is however required to use the libm crate with the dev profile.
from libm.
What 's the status of this issue (and #142)? AFAIK, it blocks rust-num/num-traits#75 .
from libm.
I haven't done anything since I commented, fuzzing was taking to long on my laptop. I'll send a pull request for what I did, which won't be guaranteed to fix all the problems, but should be an improvement.
from libm.
I'm getting linker errors, so I will be delayed a bit.
from libm.
I am getting linker errors when running cross test --target x86_64-unknown-linux-gnu
, and I'm not sure how to fix the problem. There seem to be two issues here.
One is that it can't find thou_shalt_not_panic
.
unwind_error.txt
Replacing thou_shalt_not_panic
with an infinite loop doesn't help. This one's probably related to rust-lang/rust#47493.
unwind_error2.txt
from libm.
I also get addition overflow panics with sqrt()
at lines 138, 144 and 159 of the file.
from libm.
I did some fixes here that fix the issues I was having using the vsop87
crate. Not sure if this is how we should fix them, given that the Wrapping
API is nightly-only.
from libm.
I got a subtract with overflow panic on floorf.rs just now.
Is there a way to use a function attribute to disable these checks?
from libm.
I am getting overflow errors from sin
(libm-0.1.2/src/math/sqrt.rs:168:18
) in debug mode , on the expression (45. * (core::f64::consts::PI / 180.)).sin()
. Is there a way around this, or a fix coming soon for this?
from libm.
I ended up just forking this whole thing and fixing it by hand. You can see some of the PRs for examples of how to address it. Seems the maintainer is not around anymore.
from libm.
To clear some things up: I did some initial work on this, but it was never pushed.
Then holidays ended, and I had less time to work on it. When I tried to come back to it, I got linker errors I couldn't solve.
from libm.
Hi @japaric,
Is this the right way to solve the overflow/underflow problems? #153
for me it seams more clean than using a wrapper type.
I'm willing to tackle this issue.
from libm.
I believe this can be closed now that #168 was merged.
from libm.
Related Issues (20)
- Incorrect value of sin(13.11250158914107) on x87 HOT 5
- Cortex-M4F: 'libm::sin()' is 2 times slower than 'sin()' of C newlib-libm HOT 2
- Running musl-reference-tests is impossible outside linux (and still nontrivial to run on linux)
- Pure 32-bit versions of 32-bit math functions HOT 6
- failed to compile targeting avr HOT 5
- Proving IEEE-754 2008 compliance for all sqrt/sqrtf implementations on all platforms. HOT 1
- aarch 64 compilation failure. HOT 2
- Make all symbols weak? HOT 1
- floor(), floorf(), ceil() and ceilf() Don't actually work on no-std (linker error) HOT 7
- Some functions are producing a different result than musl
- Const eval support HOT 1
- Incorrect `fmaf` results on some inputs HOT 2
- Attempt to negate with overflow in `fma`
- Potential to add #[inline} attributes where possible HOT 2
- Cargo test fails in x86_64-pc-windows-msvc target HOT 1
- Using rint/rintf instead of roundeven/roundevenf appears to break target_arch = "spirv" for spirv-std HOT 1
- Possible errors in some constants? HOT 2
- specify MSRV
- Next release? HOT 1
- Incorrect exponent calculation in the nextafter implementations leads to missed overflow/underflow signals
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libm.