Feature request: Large Integer Capability

Feedback Case Number: 62339


I submitted a feature request for adding a capability in Xojo for large integers. My hobby interest is developing ,testing and understanding math algorithms. At present I am learning number theory algorithms with special interest in prime factorization… Most algorithms need large integer support to be useful. Not very challenging to factor a 64 bit number for instance.

Currently I am using Python with has excellent big integer support. The python capability is its one and only built-in integer.

I’m pretty sure that there are other users that would find this capability useful for things like cryptography.

I tried to find duplicates in Feedback but there as so many feedback cases with “integer” in them that it made the search daunting. Sorry if this is a duplicate.

See blog article:

BigNumberMBS is a floating point with variable length up to 320bits, which is good for 100 digits in precision before the decimal dot.
LargeNumberMBS is an integer number with up to 4128 bits, which is enough for about 1224 digits in precision.
We also have an example with BigCurrency class using it for high precision currency replacement.



Thanks for the clarification on the digit size for your LargeNumberMBS plugin. Unfortunately having a fixed limit integer size for number theory algorithms is too limiting. The quadratic sieve algorithm that I am testing now easily gets to final integers that require a greater common divisor calculation that is in the high thousands of digits.

I don’t know if you’re looking for a solution or just want to put eyes on the ticket, so I don’t know if you’ve seen this one http://delaneyrm.com/DecimalPlugin.html or if its of any use to you (I’ve not tried it). Thought I’d mention it just in case you hadn’t seen it/tried it. Edit, ahh I see you’ve found it from your ticket, I’ll go back to sleep now :wink:

1 Like

In theory you could devise a large integer object yourself using a memoryblock… However you’d have to do all the math yourself also.

A UInt128 is simply two Uint64s.

there is also the fpplugin for big integers handling : http://delaneyrm.com/fpPlugin.html

1 Like

Can’t you use python directly in Xojo with the plugin from Einhugur?

I’ve mentioned this in the past, and I’ll say it again: Plug-ins are far too slow in most applications to be useful when dealing with large integers or large floating point numbers. When we are dealing with a lot of digits, it almost always means that we also need lots of speed. The overhead involved with invoking a plug-in routine usually negates its benefit.

When I filled out the recent user survey, last week, one of my two top feature requests was for 128 bit floating point numbers.

I think Xojo staff might be surprised at how many people are developing serious number crunching apps in Xojo.

1 Like

isn’t much more time spend in the plugin and embedded library for the actual number crunching comparing the small overhead of calling a plugin function?

Sam, I did make a big integer class with integers of unlimited size using memory blocks. However I could never get decent speed out of it. Xojo speed is still not on par with C/C++ with this type of number crunching. And packages such as GMP have been worked on for years and blow away most implementations. Some of the functions get quite complex (examples division and exponentiation). My implementation worked as in getting right answers but not fast enough to do serious number theory work such as prime factorization. Much too slow.

1 Like

Yes but the plugin code has to be competitive to implementations in other languages.

it"s kind of a self fulfilling prophecy. You can’t make the math programs you want to if you don’t have the capability in the tool. No capability and the programs (users) don’t happen. Then Xojo thinks there is no interest because no one is actively developing. Duh!

Yes and I can program directly in Python in Python. For most of my work I don’t really need a GUI (just need number crunching and multi-processing to speed us final apps). The issue now is that more of the code that I migrate the less I need Xojo and eventually will not need it at all. At this point I am not building cross platform or developing GUIs. I guess I may have a letting go problem. I have been dabbling in Xojo for many years and have a sentimental attachment. But eventually the paid product will loose to the free one (I am on auto renew and just renewed). Having to buy plugins just makes a hobbyist less inclined to use Xojo. I’m not against companies selling plugins. The issue is if you can’t afford them you become a have not. And if Xojo decides to not fill holes provided by commercial plugins the Xojo base capability will never evolve. Just my opinion.

BTW its not just the math capability that is better in Python. Multi-precessing is simple and elegant. And what you can do with lists, dictionaries and sets is just amazing.

I feel that Xojo has their hands full with the breadth of the product with changing frameworks and the ever increasing number of platforms being developed for. And I understand that multi-platform is their core business. I really don’t think that math capabilities will ever be addressed. But letting Xojo know my needs and opinion is just good customer behavior. And if anyone feels the same then let your voice be heard. I read in other threads something to the point “we don’t see customers using this or that” . Xojo, “I use integers a lot” and need a bette capability.

1 Like

An all goes back to the, users are happy with the tool as it is because almost no one is complaining/requesting other stuff…

The problem with making classes that act like intrinsic values is that the are still objects with the corresponding overhead. So, for example, if you try to make your class act like this:

var bi as BigInt = 5
bi = bi + 6

bi is created, then a new bi is created to hold the result, and the original is torn down.

You can get much better speed if you limit the number of times instances are created/destroyed, but it means you have to write code like this:

var bi as BigInt = 5
bi.Add 6 // Just one bi object

For all I know, you’ve written it that way already, so I’m not commenting on your work specifically. I would like to see your class though. :slight_smile:

1 Like

i’m sure that you are right about the class overhead and it was definitely written for the
bi = bi + 6 case.

it:s been a while since I worked on it and I would have to sift through the versions to find a good one to send to you. At the time I was converting to the new framework (remember that). I should have a version on the old framework and I will look when I get some time.

38472 - Support 128 bit floating point, Quad type. (LLVM fp128)

59669 - add support for 128 bit integer types

Look for “128” in this article:

Kem, i posted the source code to my big integer implementation to Github


I am no longer using it but its might be useful to someone. Or a starting place for someone.


FYI, I forked the project and converted it to text format here.

If you want to see what progress (if any) I’m making, check the other branches in that repo starting with develop.

Well, you have a LOT of code in here. In order to properly understand it, I think I have to start my own project and write my own functions as I borrow (i.e., steal) liberally from yours.

Unless you object, of course.