Results 1 to 3 of 3
Jun 5, 2009, 14:49 #1
- Join Date
- Jun 2009
- 0 Post(s)
- 0 Thread(s)
Problems dealing with large sums of money
I'm trying to do some work manipulating some monetary values that number in the tens of trillions (with cent precision, i.e. 14 digits with two decimal places-16 digits total). It needs to be scalable even higher-at least to the hundreds of trillions and perhaps to a quadrillion. Anyway, I can get Ruby to take them in and parse them fine by bringing them in as strings and then using .to_d on them and storing them in a SQLite3 database with the column type set to "NUMERIC." I've checked in the database manager and can see they're being stored fine. I am having some issues reading the numbers back out, though-when I read them out of the database and run .to_s on them, it cuts off the last decimal place (i.e. if it's supposed to read 11552130832734.01, it reads 11552130832734.0). If it's under 10 trillion, it's fine, but at or over that the 16th digit is dropped.
To fix this, I've tried using .to_d (didn't work at all), .to_s(precision = 16), .to_s('D'), etc etc all to no avail. Does anyone have any ideas on how to get this to read out & display properly?