QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: MWheatley 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
-
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
-
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
-
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.
-
No problem. I can look back through your posting history.
Malcolm
-
@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.
-
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
-
Whoops, forgot to include the web site:
http://largeint.sourceforge.net/
Wayne