paupino / rust-decimal

Decimal number implementation written in pure Rust suitable for financial and fixed-precision calculations.
https://docs.rs/rust_decimal/
MIT License
1.02k stars 183 forks source link

Fixes QUARTER_PI causing a stack overflow for cos/sin #585

Closed paupino closed 1 year ago

paupino commented 1 year ago

Fixes #584

Previously there was a check doing a >= check against quarter pi to forward a cosine request to a sine (and vice versa). Effectively if we did cos(pi/4) we'd try to fix this by doing sin(pi/2 - pi/4) - this of course is sin(pi/4). Unfortunately, sin would detect this and then forward it back to cos causing an infinite loop.