Talk:Arbitrary-precision integers (included)

From Rosetta Code
Revision as of 22:03, 5 June 2010 by rosettacode>Tinku99 (→‎Use of external libraries: laszlo's bignum library.)

Use of external libraries

I strongly recommend allowing the use of external libraries in the case where the language doesn't have inherent bignum support. Otherwise, you would need a more generalized task, and I don't see a point to the example code duplication that would require. --Michael Mol 08:33, 13 February 2010 (UTC)

Hi Michael, I am trying to distinguish between the use of a library that is associated with the language versus one that is generic. It is a grey area because, for example, CPAN does wrap GNU MP which would make it fine as you would assume that the average Perl user would have no problem installing the CPAN module. But what of some other language with a generic interface to C/C++ that needs a generic download of the GNU MP source, compiled, then loaded with a generic inter-language call capability? I am trying to exclude this latter case as we already have an entry for calling other languages and I would like this task to not degenerate into showing how half the languages can link to GNU MP.
Another grey area might be languages where the norm is to use libraries from a another language that it is very close to. All the .Net languages might use a standard Bignum implemented in C#; or JVM languages use the standard Java Bignum. In these cases, where the languages regularly and normally share 'standard' libraries, then I think they should go ahead and use it. --Paddy3118 09:14, 13 February 2010 (UTC)
I guess I'm trying to make the '... (included)' tasks show more of what comes with very little effort, and is known to work, with the language itself. --Paddy3118 09:23, 13 February 2010 (UTC)
So, you're looking for what people can do within the language or with a very common add-on library? (In some languages, it's normal and expected to be using extra libraries for things, and so the core language itself has very little functionality.) –Donal Fellows 11:49, 13 February 2010 (UTC)
Just because the mechanism behind a task is already shown somewhere else doesn't mean we shouldn't allow the usage of that mechanism to solve a different problem. If we were to generalize that as a rule, most of the tasks on Rosetta Code would be defunct because we have tasks for looping and flow control. By their very nature, people tend to go with least-effort solutions, and for any given language, the least-effort solution to an expert will be idiomatic for that language. If a language has good support for arbitrary precision, an expert in that language is likely to use the native support. If the language has poor support, the expert in that language will prefer to pull in an outside library. --Michael Mol 16:38, 13 February 2010 (UTC)
Can we get some more chimes in? I haven't forgotten about this; I've just been too busy to come back to it. I really don't care for requiring the use of builtins for a sophisticated problem, as I think a savvy developer in a language would favor builtins over imported functionality, but I'd like to know what other people on here think. (Do we have a name for contributors around here?) --Michael Mol 14:53, 25 February 2010 (UTC)

I was rather hoping people would demonstrate how to write an arbitrary-precision / bignum library, in their preferred language, from scratch. I've been scribbling ideas on the train / bus to and from work. Um, err, yes ... in VBScript. Of course, it wouldn't necessarily be very efficient in that language, but, once working, it might be better in VB6 ... --Axtens 13:31, 13 February 2010 (UTC)

Hi Axtens, You could write a task to, say, compute the same number using only, say, 16 bit integers, but I think a full-blown Bignum implementation would become too large to compare implementations? I did the easy one ;-)
--Paddy3118 16:21, 13 February 2010 (UTC)
You might find Long multiplication interesting. Also, I'm almost certain I created a long division task, but I don't see it anywhere. A better way to ask for what you're looking for might be to ask for implementations of particular algorithms. I don't know the names of many relevant algorithms off-hand, though; perhaps some of the CS majors could chime in. --Michael Mol 16:28, 13 February 2010 (UTC)
Bignum engines are fairly large. I've just checked the Tcl sources, and our core bignum engine is 4600 lines of C for just basic mathematical operations (division takes a lot it seems). OK, that includes comments but even so, it's all a bit much for RC. Given the general difficulty of writing a bignum implementation that doesn't suck, every language that provides built-in bignums will be using one of the existing libraries for it. –Donal Fellows 08:15, 14 February 2010 (UTC)
Laszlo's bignum library in a combination of 450 lines of ahk and 330 lines of c... Tinku99 15:49, 4 June 2010 (UTC)tinku99
If Laszlo would try and get his/her code accepted as the Bignum library for AHK and put in the normal place for AHK's endorsed libraries mentioned with the distribution, then you would be doing the AHK community a favour as well as merely extending Rosetta Code. More power to Laszlo! --Paddy3118 20:02, 4 June 2010 (UTC)
My impression from watching AHK progress on RC is that the AHK forums are the go-to place for AHK libraries and modules. An unusual approach, to be sure, but that's been my impression. I haven't done specific research on it. --Michael Mol 20:20, 5 June 2010 (UTC)
Yeah, there isn't an official library. The forum and the wiki are it. Laszlo is the goto person for math related things in autohotkey. I have added a link to it on the wiki as well.

Criteria for Non-Draft?

What are the criteria for making this page a full task? There are already a number of implementations and the task itself is largely clear too. –Donal Fellows 11:51, 13 February 2010 (UTC)

I'm pretty sure there are no criteria. It's just a consensus. This one seems to still have a little discussion going on about how we want it to work so maybe we should wait to make it a full task. --Mwn3d 16:45, 13 February 2010 (UTC)
Whoops. I've changed it already due to the number of examples. Please put it back in draft if you think it needs it though. --Paddy3118 16:58, 13 February 2010 (UTC)

“Precision”

Is the use of “precision” appropriate? To me, “precision” suggests fractional digits (to the right of the decimal[-or-binary] point). —Kevin Reid 12:55, 13 February 2010 (UTC)

Hi Kevin, I've heard it used colloquially as "the number of digits of precision of an integer", and also shortened to just "the number of digits". I guess, because we are dealing with integers which are usually thought of as without an exponent then the "range" of an integer might be used instead, but the wp article uses precision when speaking of integers:
"In computer science, arbitrary-precision arithmetic is a technique whereby calculations are performed on numbers whose digits of precision are limited only by the available memory of the host system. This contrasts with the faster fixed-precision arithmetic found in most ALU hardware, which typically offers between 6 and 16 decimal digits. It is also called bignum arithmetic, and sometimes even "infinite-precision arithmetic" (which is a misnomer, since the number of digits is both finite and bounded in practice)."
--Paddy3118 16:54, 13 February 2010 (UTC)

Ursala took a day?

On my four year old laptop, the Python version took around a minute to run. Maybe the Ursala version should not have used BCD if another representation is available? --Paddy3118 19:08, 8 April 2010 (UTC)

Time constriction?


Copied from User talk:Short Circuit:

Sorry, to bother you again. I have written some code for the task "Arbitrary-precision_integers_(included)" in the programming language AutoHotkey. Now my problem here is the following: the code runs on my PC for 26 hours and then spits out the correct result. I have used an implementation of BCD multiplication by AHK forum user Laszlo (permission has been granted to publish his code) together with my own implementation of "long powers", that held tight when tested with Euler Challenges. I am as sure as I can possibly be, that this code is correct (forum discussion starts with the second post from the top here: AHK forum, if you want to have a look). Now I think that pride thing you mentioned yesterday has got a grip on me too, so here is my question: Is there a time constriction at all for submissions to RosettaCode? I assure you that this is not some untested, half-baked code that gets thrown at RosettaCode, but it can be improved. Wolf 12.May 2010 14:32h (GMT+2)

No time constriction. --Michael Mol 13:42, 12 May 2010 (UTC)
But isn't a condition of that task that it is only solvable by languages that come with their own in-built implementation of arbitrary precision integers? If you are having to code it then it should not be included. --Paddy3118 14:09, 12 May 2010 (UTC)
You're correct. And this is a discussion better suited for that task's talk page. --Michael Mol 14:22, 12 May 2010 (UTC)



END Copy, and continue...