Ask HN: largest number you've had to store in an application?

15 points by mellis ↗ HN
For a "real" purpose (as opposed to a user banging on the keyboard). Just curious when / if / why we'll need more than 64 bits.

25 comments

[ 2.7 ms ] story [ 57.1 ms ] thread
Do parts of RSA keys count?
twitter id's is the first thing that comes to mind.
These are also the largest numbers I've had to store, however 64 bits should suffice for a very very long time for twitter id's. If everyone on earth (assuming 6 billion people) tweeted 100 times per day, it would take over 84 million years to overflow 64 bits.
But if you had 84 million inhabited planets, with 10 tweets a day, it would only take 10 years (correct me if my math is wrong).
I used to work for an egg wholesaler. We paid the farmers by the egg according to grade. We accounted in eggs.

Do you know how many eggs are sold in the UK?

We had to write a special class to handle eggs because we blew the unsigned integer on a VAX.

Bignums, my friend. BCD is also good for real-world numbers, like money or eggs.
If you want universal uniqueness you should be looking at 128-bits (http://en.wikipedia.org/wiki/Universally_Unique_Identifier)
If you want universal uniqueness, 128 bit won't last you too long. The number of atoms in the universe is estimated to be around 10^80, so you'd need about 266 bits to address every single atom. Give it some headroom, go to 512 bits...
8374874823748327491
EPC Gen2 RFID tags have a 96 bit unique id that we store
Heh, I actually overran a signed integer 2 years ago in an app for a major financial company.

Yes, that's > $2,147,483,647

Thanks, subprime mortgage crisis!

You don't have much space left in 64 bits for some financial numbers. FX swap trades with a billion dollars on one side and some very devalued currency on the other (e.g. zimbabwe dollars 1:60,000,000 at one point).

It gets worse when you start adding those numbers up.

I have worked on Financial Apps where we have ended up blowing away the 64-bit threshold.
Huge. Longer than 2^30 digits. I was working on statistics. Doing probabilities requires doing some crazy factorials. These often require handling large freaking numbers. I'm a PHP guy, so BC Math and GMP Math are my saviors in this area.

Thankfully, all the huge numbers are just in the computation of the statistics and don't need to be stored long term in a database. The thought of having to store an integer in a BLOB is frightening.

I stumbled across a database where I work where videos were being stored not in the filesystem, but as BLOBs in a DB. Thrilling.
You can usually get away with storing the log-factorials, and then just taking the exponent at the end. (If you don't have an arbitrary precision library handy, or computational speed is an issue.)
I've had to build a system to theoretically handle indexes up to 1.2553643905927429e+30 but we haven't got that far yet (biggest # is a billion billion billion or so)
public/private keys for RSA - 1024 bit numbers.
I built an aviation mapping engine that used fixed point math for lat/lon representation. It basically used an entire 32bit signed int and gave a guaranteed minimal resolution of 3 feet. It would quite often go to the ragged edge of what you can fit in a 32 bit quantity.

The fun bit was that you had to use 2 combined registers (ARM) to represent a 64bit quantity so you could do multiplication and keep all your precision.

Oh, for the luxury of a FPU...

I implemented Tupper's Self-referential formula which depends on an extremely large number (although I suppose that's cheating a bit, the number is actually an encoding of a bitmap).
1000000! took me about an hour to calculate on a supercomputer in 1988. It's roughly 5 million decimal digits.
I guess astronomical modeling uses ... astronomically big numbers?