kaue / bbp-formula

🔢 Bailey-Borwein-Plouffe formula
MIT License
9 stars 0 forks source link

Can this version generate infinite precision if the precision is not specified? #1

Open kaue opened 5 years ago

kaue commented 5 years ago

Issue reported at https://github.com/MikeMcl/decimal.js/issues/9#issuecomment-441381356

kaue commented 5 years ago

@calidion currently the precision is defined at https://github.com/kauegimenes/bbp-formula/blob/master/index.js#L3 I was thinking about making it an option something like that: const calculatedPi = bbp(0, {precision: 100000});

That would work for you?

calidion commented 5 years ago

Is it the maximum precision?

calidion commented 5 years ago

I would like to have a program to have infinite precision ability, if precision is not specified. I would get output like this.

3.1415926...

each digital is generated overtime, and will continue to put new digital to the next precision. like this program: https://bellard.org/pi/pi.c

kaue commented 5 years ago

from decimal.js source:

   // The limit on the value of `precision`, and on the value of the first argument to
    // `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`.
    MAX_DIGITS = 1e9,                        // 0 to 1e9

I can update the precision to be equal to 1e9 by default, that would work for you?

calidion commented 5 years ago

Can the precision be dynamic?

kaue commented 5 years ago

Not sure

calidion commented 5 years ago

Would you consider this algorithm? https://bellard.org/pi/pi2700e9/pipcrecord.pdf It seems no need to use Decimal, normal javascript primitives will be ok.

kaue commented 5 years ago

@calidion I don't have time to make big changes to this package, but feel free to create a PR if you want to.

calidion commented 5 years ago

OK.

kaue commented 5 years ago

@calidion any progress on this? ;)

calidion commented 5 years ago

Sorry, I don't have time currently.

kaue commented 5 years ago

Oh, no problem. i hope we can add stuff to this package in the future.