in reply to Re^6: Why am I losing accuracy?
in thread Why am I losing accuracy?

I am thinking to reply with maybe bignum should be put under the ACME tree? but holding back thinking I am too extreme. I still can't digest that forloop behaviour. Fair enough it's a design choice but the unawary, common-sense Perl user is in for a big surprise when trying to ... increase precision.

Replies are listed 'Best First'.
Re^8: Why am I losing accuracy?
by haukex (Archbishop) on Jan 12, 2020 at 15:08 UTC
    Fair enough it's a design choice but the unawary, common-sense Perl user is in for a big surprise when trying to ... increase precision.

    I'm a little confused (about the whole subthread, actually, as well as this one) - isn't p=>1 explicitly asking for reduced precision?

      haukex:

      Yes, it's asking for reduced precision, but I think that bliako is surprised as I am by the sign of the precision argument. The various number formatting tools I've used have given me the expectation that a positive number indicates the number of digits I want to retain to the right of the decimal place, rather than to the left.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        yes, for me the sign of precision is confusing.

        I am also confused as to what precision and what accuracy mean for bignum and why in incrementing an integer (for example, in the loop) precision discards useful digits to replace them with zeros.

        What perl -Mbignum=p,1 -wle '$i = 1; print $i + 123456788,"\n"' does is round((1+123456788)/10) * 10 =  123456790 Why? Just add the numbers please? At least when the "width" of the largest can accommodate the result too. Instead it discards the LS"D" of the result and replaces it with a zero. The more increasing p the more LS"D"s are thrown away but the width of the result is not getting any smaller, so what's the practical reason?

        From roboticus home node I clicked on dominus home node and then on to his blog which happens to talk about bc just a few days ago. And points out that bc adding two numbers increases the number of digits to accommodate the result. Well bignum does that and then replaces "p" LS"D"s with zeros. thanks.

        edit: LS"D" = least significant digit