I'm making a site which does crazy comparisons. You can, for instance, choose cow, earth, and 1e20 in order to find out how deep in cow slurry we would be if 1e20 cows rained down onto the earth.
The large numbers occur when you specify extreme comparisons. How many electrons would it take to fill the total volume in the known universe? How many seconds would it take for a snail to travel across the known universe?
Then there are the arbitrary comparisons like: How many Milky Way Galaxies would it take to equal the mass of 1e5000 cows? In this case the user can enter numbers which are arbitrarily large and get results back which are correspondingly large.
This all works fine when I stay inside the Java VM because I'm using BigDecimal numbers which can be arbitrarily large. But, if I want to store a result in the DB, I'll need to be able to store the BigDecimal parameters in the DB.
At the moment I'm putting checks in various places to prevent results which are over 1e308. But the whole point of the site is to be absurd. I want to be able to use numbers of arbitrary size.
I know that it's possible to create new datatypes in postgres. I once used an add-on which added a new type which could be used for more advanced text searches. I'm just hoping that there is a BigDecimal-like add-on for postgres. If not, how do I create new data types in postgres?
Main Topics
Browse All Topics





by: grant300Posted on 2008-04-07 at 14:57:17ID: 21300914
Just out of curiosity, what are you working on that has meaningful numeric quantities with a 6 digit exponent? 1*10E308 is probably (literally) more atoms than there are in the galaxy, maybe the universe.
Planck's constant is 6.626E-34 Js and represents a fundamental energy quanta. Avogadro's number is 6.02E23 and represents the number of individual atoms in a mole of matter. These are the largest and smallest physical quantities that I can think of and then only vary by a factor of 1E57.
Regards,
Bill