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
| [reply] [d/l] [select] |

*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*
When you specify `p => 1` you're actually saying that you want the values rounded to the nearest multiple of 10.
To have the values rounded to the nearest multiple of 100, specify `p => 2`. For rounding to the nearest multiple of 1000, specify `p => 3`, and so on.
So, with `p => 1`, 10 + 1 == 10 and 10 + 6 == 20, because 11 rounded to the nearest multiple of 10, is 10 and 16 rounded to the nearest multiple of 10 is 20.
OTOH, `a => 1` indicates that you want the value rounded to a value that comprises a single digit multiplied by a power of 10, `a => 2` indicates that the value should be rounded to a double-digit value multiplied by a power of 10.
It seems to me that "accuracy" would be better named "precision". (The trailing zeroes are just the exponent - it's the number of leading digits ahead of the exponent that determines the precision of the value.)
Not sure what "precision" should be renamed to .... "accuracy" ?
I think negative values for "p" just tell you how many decimal places you want after the decimal point.
With practice and experience it's probably useful - if you keep your wits about you. (I have not tested this - the reliance on "wits" deters me.)
Cheers, Rob
| [reply] [d/l] [select] |

| [reply] |

Comment onRe^9: Why am I losing accuracy?