Page 1 of 1
Big number library
Posted: Sat Sep 04, 2010 2:37 pm
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.
Cheers,
Lewis
Re: Big number library
Posted: Sat Sep 04, 2010 4:20 pm
by Trond
It is a good idea, and probably not too hard to implement.
Re: Big number library
Posted: Sat Sep 04, 2010 4:21 pm
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
Re: Big number library
Posted: Sat Sep 04, 2010 7:56 pm
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.
Re: Big number library
Posted: Sat Sep 04, 2010 8:04 pm
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?

Re: Big number library
Posted: Sat Sep 04, 2010 8:18 pm
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?

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"

) 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.)
Re: Big number library
Posted: Sat Sep 04, 2010 8:38 pm
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
Re: Big number library
Posted: Sun Sep 05, 2010 7:36 pm
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)!
Re: Big number library
Posted: Sun Sep 05, 2010 10:25 pm
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

, 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
Re: Big number library
Posted: Sun Sep 05, 2010 11:54 pm
by STARGÅTE
Michael Vogel apology, I have it confused with a different theme.
Did my other post edited.
I'm sorry really
Re: Big number library
Posted: Mon Sep 06, 2010 11:09 am
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

)
Re: Big number library
Posted: Mon Sep 06, 2010 12:36 pm
by blueznl
If bignums would be easy uncle Fred might have to define a new type, '.z' or something

Re: Big number library
Posted: Mon Sep 06, 2010 10:07 pm
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.
Re: Big number library
Posted: Fri Sep 10, 2010 12:45 pm
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?
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
Re: Big number library
Posted: Fri Sep 10, 2010 2:11 pm
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?
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?