Skip to content

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

Comments

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.)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.