in reply to Why am I losing accuracy?

See the Math::BigInt docs in regards to its div_scale parameter: "This is the accuracy used when neither accuracy nor precision is set explicitly. It is used when a computation might otherwise attempt to return an infinite number of digits." The default value is 40, which is what you're seeing there.

You can either pass an accuracy to the bdiv method explicitly, for example: $digest = $digest->bdiv(64, 1000)->as_int;, or perhaps do this instead: use Math::BigRat; Math::BigRat->new($digest, 64)->as_int;, both of these result in your desired answer. (There are probably one or two other methods but these are the first I've thought of.)

Replies are listed 'Best First'.
Re^2: Why am I losing accuracy?
by ikegami (Patriarch) on Jan 06, 2020 at 09:10 UTC

    Could also use $digest->brsft(6); (since 64 is 26)