Giter Site home page Giter Site logo

Comments (15)

MarkSwanson avatar MarkSwanson commented on September 5, 2024 2

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.

vjackson725 avatar vjackson725 commented on September 5, 2024

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.

japaric avatar japaric commented on September 5, 2024

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.

little-arhat avatar little-arhat commented on September 5, 2024

What 's the status of this issue (and #142)? AFAIK, it blocks rust-num/num-traits#75 .

from libm.

vjackson725 avatar vjackson725 commented on September 5, 2024

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.

vjackson725 avatar vjackson725 commented on September 5, 2024

I'm getting linker errors, so I will be delayed a bit.

from libm.

vjackson725 avatar vjackson725 commented on September 5, 2024

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.

Razican avatar Razican commented on September 5, 2024

I also get addition overflow panics with sqrt() at lines 138, 144 and 159 of the file.

from libm.

Razican avatar Razican commented on September 5, 2024

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.

jackmott avatar jackmott commented on September 5, 2024

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.

dbeckwith avatar dbeckwith commented on September 5, 2024

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.

jackmott avatar jackmott commented on September 5, 2024

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.

vjackson725 avatar vjackson725 commented on September 5, 2024

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.

Schultzer avatar Schultzer commented on September 5, 2024

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.

vks avatar vks commented on September 5, 2024

I believe this can be closed now that #168 was merged.

from libm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.