cmpute / dashu

A library set of arbitrary precision numbers implemented in Rust.
Apache License 2.0
74 stars 9 forks source link

infinite loop in `powf` and `ln` #44

Closed Shoeboxam closed 7 months ago

Shoeboxam commented 7 months ago

Thanks for making this library! I've discovered some bugs while experimenting with taking it on as a dependency for OpenDP (https://github.com/opendp/opendp).

I'm using dashu 0.4.

powf infinite loop

FBig::<Up>::from(2).powf(&FBig::from(2));

Only gets stuck when the rounding is Up. Gets stuck for any choice of nontrivial power.

ln infinite loop

FBig::<Up>::from(2).ln()

Only gets stuck when the rounding is Up.

powf panic

The following expression causes dashu to panic:

FBig::<Up>::from(0).powf(&FBig::from(2));

This panic happens on any of the rounding modes I've tested.

Thanks!

cmpute commented 7 months ago

Thanks for reporting this, will take a look.

Shoeboxam commented 7 months ago

The key function I need at this point is ln. From debugging the code it gets stuck in the loop inside fn iacoth: next is always a factor of 10 larger than sum.

cmpute commented 7 months ago

This should be fixed now. Please try the new published version 0.4.1 and feel free to reopen when the bug persists.