0

I'm kind of a newbie with c++ so just a heads up there. I have added a third party arbitrary precision arithmetic library called "bigfloat" to my c++ project (https://github.com/Mariotti94/BigFloat) because I need some high precision when calculating pi with the chudnovsky algorithm as the factorials in the equation overflow very quickly but it seems that the variables associated with the third party library are not declared in cmath and therefore the program runs into some errors when I try to use the pow() function in the main equation.

sum += ((426880.0*sqrt(10005.0))/((firstifac)*((545140134.0*i)+(13591409.0)))/((secondifac)* 
(pow(thirdifac,3.0))*pow(-262537412640768000.0,i)) );
// main equation

When I tried to run the program, it came up with the 4 following errors saying:

error: no matching function for call to 'pow(BigFloat&, int)'|

error: no type named '__type' in 'struct __gnu_cxx::__promote<BigFloat, false>'|

error: no matching function for call to 'pow(long long int, BigFloat&)'|

error: no type named '__type' in 'struct __gnu_cxx::__promote<BigFloat, false>'|
|

and because I'm a bit naïve when it comes to c++ I thought that in line 406 of the cmath library:

inline long double
  pow(long double __x, int __n)
  { return __builtin_powil(__x, __n); }

I could just substitute "long double" for "BigFloat" but unsurprisingly, that didn't work and I'm unsure of how to establish the BigFloat variable in the pow() function. if anyone knows how to establish the variable or knows a more efficient way I would be very grateful.

  • I think you can't use the pow() function. This library would have to provide an implementation for BigFloat – drescherjm Mar 23 '22 at 19:47
  • Looks like `BigFloat` doesn't advertise a `pow` function or anything like it. if the exponent is an integer you can get away with a multiplication loop without much difficulty. The `3q+3/2` term kinda ruins this idea. – user4581301 Mar 23 '22 at 19:50
  • If you edit the question to expand on what you are trying to do you'll be in a much better position to get a useful answer. – user4581301 Mar 23 '22 at 19:51
  • Do you really need to calculate pi? Is it an exercise, or you need it for some other calculations? Having pi already stored in memory makes things much faster, for example you can take 10 million digits of pi from [here](https://introcs.cs.princeton.edu/java/data/pi-10million.txt) and hard-code them into you program. Or you can calculate like 40 billion pi digits using [GNU MP](https://gmplib.org/pi-with-gmp). For more digits than that you will need the [y-cruncher](http://www.numberworld.org/y-cruncher/). – Arc Mar 25 '22 at 18:01
  • Its just an exercise but I'll consider using GNU MP as an alternative. Thanks! –  Mar 25 '22 at 20:28

0 Answers0