Ticket #32 (new enhancement)

Opened 11 months ago

Last modified 2 months ago

Bignums?

Reported by: JarrettBillingsley Assigned to: JarrettBillingsley
Priority: normal Milestone:
Component: Stdlib Keywords:
Cc:

Description

Support for arbitrary-precision integers? They tend to be useful. Should they be a basic type, or should they be implemented as objects? hmm..

Change History

01/16/08 08:34:42 changed by Ligustah

AFAIK Python automatically converts Integers to Bignums, if they exceed the capacity of an Integer. Maybe that would be possible in MiniD as well. If you add them, i'd do it as an object. Maybe the interpreter could automatically insert such an object if your code contains something like this:

//a number that should be too large for an integer
local number = 392_348_293_842_394_823_984_102_389_123_489_123; 

Ligustah

01/16/08 09:32:15 changed by JarrettBillingsley

Python is indeed probably the best reference for this. I wonder, though, what kind of performance impact checking for overflow on every integer math operation has. MiniD currently is ~30% faster than Python when it comes to integer math (for normal ops.. for reflexive ops like +=, it's like, 100% faster).

01/16/08 12:58:16 changed by Ligustah

Wow 100%. Probably it would be best to make a little testcase, as far as it is not too difficult.

Ligustah

06/03/08 23:11:32 changed by the_darkside_986

What about implementing it as a class but it must be explicitly instantiated? Anyone writing a numerical-intensive application (such as a desktop calculator program) should know the basics of data type ranges and use the appropriate data types (short, double, etc.). seems like checking each int operation would add too much overhead, especially for developers who know exactly which storage types they need.

06/04/08 00:19:06 changed by JarrettBillingsley

You're probably right. To be implemented efficiently they'd have to be reference types as well..

I'd like to have them regardless. Now the question is: do I really feel like implementing them? Or do I feel like ganking Python's implementation ;) Or maybe just binding to GMP.

10/13/08 13:58:18 changed by JarrettBillingsley

Tango's getting bigints on the next release, so this should be easy to add.

10/15/08 18:32:42 changed by JarrettBillingsley

  • component changed from Language to Stdlib.

I'm moving this to stdlib since that's where they'll probably end up, if I add them.

10/17/08 09:25:50 changed by JarrettBillingsley

  • milestone deleted.

Removing milestone as I don't think the new Tango will be out before MD2 goes gold. Even if it does, there are more pressing matters.