Big number library

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Lewis
User
User
Posts: 47
Joined: Fri Nov 25, 2005 1:12 pm

Big number library

Post by Lewis »

Since this is most likely of interest only to mathematical researchers only, it is unlikely to be a priority task. Nevertheless, it is now requested -- and hopefully not to be forgotten. :wink:

Cheers,
Lewis
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Big number library

Post by Trond »

It is a good idea, and probably not too hard to implement.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Big number library

Post by IdeasVacuum »

Michael Vogel has some very fast code for big numbers, 'Vogels Number Format'

Searching for 'VNF' you will find this link and others:
http://www.purebasic.fr/english/viewtop ... 8&start=45
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Big number library

Post by STARGÅTE »

Michael Vogel inlcude works complete with strings, of course, is that simple in the handling but langs bunting in large numbers.
Edit: Michael Vogel inlcude works with Arrays too!

Here's another Include (by me) that works with long arrays.
Include - unlimited decimals

or from CHW89 : BigDecimal - Include

An integrated and optimized Lib in PureBasic would beat it all, so the speed would be even higher.

But for most things which are written with PureBasic (games, applications, DLLs) you need something like not many out there quads and doubles.
Last edited by STARGÅTE on Sun Sep 05, 2010 11:55 pm, edited 1 time in total.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Big number library

Post by freak »

Trond wrote:It is a good idea, and probably not too hard to implement.
You say that a lot recently... wanna do it? :P
quidquid Latine dictum sit altum videtur
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Big number library

Post by Trond »

freak wrote:
Trond wrote:It is a good idea, and probably not too hard to implement.
You say that a lot recently... wanna do it? :P
Would you include it? It would need some compiler support (like quads on x86). The big problem (which I didn't think about when saying "not too hard" :oops: ) is the powerpc support. X86 has some very nice assembly opcodes for managing huge integers easily and fast.

And I'm thinking about big integers, big floating point numbers are hard.

(By the way, when I say "not too hard", I think of the skill level, not the amount of time needed, which often is big even on "easy" projects.)
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Big number library

Post by Little John »

Well, it's not necessary to re-invent the wheel. :-)
PB already has built-in support for some third-party libraries, e.g. regarding XML or Regular Expressions.
Maybe it would make sense to build in support for a third-party Bignum library (such as GMP) as well? Just an idea.

Regards, Little John
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Re: Big number library

Post by Marco2007 »

Little John wrote:Just an idea.
...I think, it`s a very good idea, if it`s "easy" to implement (although I`m not the biggest fan of all those GNU LGPL, MIT,BSD, ... whatsoever-licenses)!
Last edited by Marco2007 on Mon Sep 06, 2010 5:30 pm, edited 1 time in total.
PureBasic for Windows
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Big number library

Post by Michael Vogel »

STARGÅTE wrote:Michael Vogel inlcude works complete with strings, of course, is that simple in the handling but langs bunting in large numbers...
Hm, din't know that :shock:, all the math functions work with integer arrays (and are faster than all other posted so far :roll:). The main restriction of my VNF functions is the limitation in handling integer values only...

Michael

PS I would like to see a math lib (and others) within the Purebasic package – if not done by the PB team then something like a "certified by fred" lib, this would help sharing code using standardized keywords

PSS for integer only I found a nice project (including c source) which is called Aribas, could be interesting for some of you as well
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Big number library

Post by STARGÅTE »

Michael Vogel apology, I have it confused with a different theme.
Did my other post edited.
I'm sorry really
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Big number library

Post by Michael Vogel »

STARGÅTE wrote:Michael Vogel apology, I have it confused with a different theme.
Did my other post edited.
I'm sorry really
Don't panic – I haven't had a sleepless night (only wailed 10 minutes or so :lol:)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Big number library

Post by blueznl »

If bignums would be easy uncle Fred might have to define a new type, '.z' or something :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Big number library

Post by freak »

Michael Vogel wrote:PS I would like to see a math lib (and others) within the Purebasic package – if not done by the PB team then something like a "certified by fred" lib, this would help sharing code using standardized keywords
And what happens if such a "certified" lib becomes incompatible to a new PB version? There used to be some userlibraries included in PB, but it never ended well because sooner or later they broke and the original developer wasn't around to maintain it anymore. If we include something in PB, we have to maintain it ourselves. Everything else is too big a risk.
blueznl wrote:If bignums would be easy uncle Fred might have to define a new type, '.z' or something :-)
A builtin datatype doesn't make much sense, as none of the regular PB libraries would be able to deal with these values anyway.

As Lewis said, its not something that most PB users will have a use for, so better don't get your hopes up.
quidquid Latine dictum sit altum videtur
User avatar
Lewis
User
User
Posts: 47
Joined: Fri Nov 25, 2005 1:12 pm

Re: Big number library

Post by Lewis »

freak wrote:
Michael Vogel wrote:PS I would like to see a math lib (and others) within the Purebasic package – if not done by the PB team then something like a "certified by fred" lib, this would help sharing code using standardized keywords
And what happens if such a "certified" lib becomes incompatible to a new PB version? There used to be some userlibraries included in PB, but it never ended well because sooner or later they broke and the original developer wasn't around to maintain it anymore. If we include something in PB, we have to maintain it ourselves. Everything else is too big a risk.
blueznl wrote:If bignums would be easy uncle Fred might have to define a new type, '.z' or something :-)
A builtin datatype doesn't make much sense, as none of the regular PB libraries would be able to deal with these values anyway.

As Lewis said, its not something that most PB users will have a use for, so better don't get your hopes up.

Well, GMP (http://gmplib.org/) has been active since 1991 and, since it's under the GNU umbrella, is unlikely to be abandoned (actually, it's usually updated once a year). I'd say that warrants a PB library interface -- don't you agree? :wink:

I'll take a closer look at the Vogels Number Format link given by IdeasVacuum. Perhaps it has something to offer.
BTW, a Google search on Vogels Number Format didn't find anything of immediate interest. Perhaps one of the VERY lesser known works?

Personally, I'm only interested in working with big integers, not floating point numbers.

Cheers,
Lewis
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Big number library

Post by Trond »

Lewis wrote:Well, GMP (http://gmplib.org/) has been active since 1991 and, since it's under the GNU umbrella, is unlikely to be abandoned (actually, it's usually updated once a year). I'd say that warrants a PB library interface -- don't you agree? :wink:
Using GNU software in commercial software is difficult because of licensing issues.
I'll take a closer look at the Vogels Number Format link given by IdeasVacuum. Perhaps it has something to offer.
BTW, a Google search on Vogels Number Format didn't find anything of immediate interest. Perhaps one of the VERY lesser known works?
He's a forum user and created this for PB.
Personally, I'm only interested in working with big integers, not floating point numbers.
Apart from +, -, *, /, %, shifts, comparisons and to<->from string conversion, what functionality would you need?
Post Reply