Author Topic: The GNU Multiple Precision Arithmetic Library  (Read 4440 times)

0 Members and 1 Guest are viewing this topic.

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
The GNU Multiple Precision Arithmetic Library
« on: September 29, 2019, 09:01:39 am »
Over the years, I've seen several people post here about ultra-high precision computing.

I hadn't previously heard of the GNU Multiple Precision Arithmetic Library, but it seems it's a well-regarded library of routines for high-precision computing, written in C, where the precision is only limited by the computer's memory.  You can calculate pi to billions of digits, if you want.

There are "wrappers" for popular languages (Python, Fortran, etc), but nothing it seems for BASIC, in any flavour.  Shame.  (The Python wrapper is the "bigfloat" package.)

Anyway, I thought I'd bring it to your collective attention...

https://gmplib.org/

Malcolm

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: The GNU Multiple Precision Arithmetic Library
« Reply #1 on: October 01, 2019, 08:07:39 am »
I did some experiments with mpfr https://www.mpfr.org here https://www.qb64.org/forum/index.php?topic=1175.0
I also experimented with gmp, but nobody is interested in stuff like that
« Last Edit: October 01, 2019, 08:10:48 am by jack »

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Re: The GNU Multiple Precision Arithmetic Library
« Reply #2 on: October 01, 2019, 09:59:21 am »
Wow.  Impressive stuff.

By the way, were you aware of Julien Sprott's book Numerical Recipes: routines and examples in BASIC?  He translated a lot of the old Numerical Recipes algorithms into QB45.  (That's JuliEn, by the way -- not a typo.)

I will study what you put in your examples.  Building a QB64 wrapper for the GNU library might be a worthwhile project.

Malcolm

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: The GNU Multiple Precision Arithmetic Library
« Reply #3 on: October 01, 2019, 10:48:51 am »
one problem is that QB64 does not have an intrinsic data type that's the size of a pointer except ~offset but ~offset can't be used as normal integer, so functions in gmp that return a 32 or 64-bit integer depending on whether you are compiling for 32 or 64-bit don't have a generic solution, you would need 32 and 64-bit bit versions of the header, and that's just for one platform, windows and linux have different datatype sizes.
besides, QB64 string functions don't play well with C-strings, I don't feel like presenting an example, I have done so in the past.

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Re: The GNU Multiple Precision Arithmetic Library
« Reply #4 on: October 01, 2019, 11:11:34 am »
No problem.  I can look back through your posting history.

Malcolm

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: The GNU Multiple Precision Arithmetic Library
« Reply #5 on: October 02, 2019, 09:11:29 am »
@MWheatley
perhaps you misunderstood, I meant that I din't feel like posting about the string problem, however if you are interested in using gmp with QB64 then I will post what I have, but it's far from perfect.

Offline wutz

  • Newbie
  • Posts: 4
    • View Profile
Re: The GNU Multiple Precision Arithmetic Library
« Reply #6 on: October 12, 2019, 09:25:31 am »
Here is a site that has 'Big Number' library routines written in, and for, BASIC.
There Lots of example .bas files that use the library routines as well. 
It looks like some were written for FreeBasic, but depending what features they use from FreeBasic, they usually are fairly easy to port to QB64.

Wayne

Offline wutz

  • Newbie
  • Posts: 4
    • View Profile
Re: The GNU Multiple Precision Arithmetic Library
« Reply #7 on: October 12, 2019, 09:27:16 am »
Whoops, forgot to include the web site:

http://largeint.sourceforge.net/

Wayne