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

Overflow panic in atan2 #7

Open
kosz78 opened this issue Nov 15, 2022 · 0 comments
Open

Overflow panic in atan2 #7

kosz78 opened this issue Nov 15, 2022 · 0 comments

Comments

@kosz78
Copy link

kosz78 commented Nov 15, 2022

Example

type Fixed = fixed::types::I32F32;

fn main() {
    let y = Fixed::overflowing_from_str("0.3333392185").unwrap().0;
    let x = Fixed::overflowing_from_str("-0.0000000002").unwrap().0;
    println!("{}, {}", x, y);
    let res = cordic::atan2(y, x);
}

Error

x=-0.0000000002, y=0.3333392185
thread 'main' panicked at 'attempt to add with overflow', /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\library\core\src\ops\arith.rs:133:1
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\/library\core\src\panicking.rs:143
   2: core::panicking::panic
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\/library\core\src\panicking.rs:48
   3: core::ops::arith::impl$10::add
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\library\core\src\ops\arith.rs:126
   4: fixed::arith::impl$1870::add<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm,typenum::bit::B1>,typenum::bit::B0>,typenum::bit::B0>,typenum::bit::B0>,typenum::bit:
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\fixed-1.15.0\src\arith.rs:118
   5: cordic::cordic_circular<fixed::FixedI64<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm,typenum::bit::B1>,typenum::bit::B0>,typenum::bit::B0>,typenum::bit::B0>,ty
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cordic-0.1.5\src\lib.rs:36
   6: cordic::atan<fixed::FixedI64<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm,typenum::bit::B1>,typenum::bit::B0>,typenum::bit::B0>,typenum::bit::B0>,typenum::bit:
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cordic-0.1.5\src\lib.rs:121
   7: cordic::atan2<fixed::FixedI64<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm,typenum::bit::B1>,typenum::bit::B0>,typenum::bit::B0>,typenum::bit::B0>,typenum::bit
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cordic-0.1.5\src\lib.rs:145
   8: cordic_test::main
             at .\src\main.rs:7
   9: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\library\core\src\ops\function.rs:227
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