>> require 'bigdecimal'
=> true
>> BigDecimal.new(103123.98.to_s).to_f
=> 103123.98
>> BigDecimal.new(100123.98.to_s).to_f
=> 101239.8
Strangely enough, if you have a "0" as the fourth digit to the left from the decimal point when you build a big decimal object, it cuts it out. I have no idea why this is. I don't have time to investigate it. But I do know it doesn't happen with ruby 1.8.6, which is what I'm running in production, so for the moment it's not a real problem for me (except I had to change all my tests that had a 0 in that decimal place temporarily while I sort out bringing an older version of ruby onto my machine).
*sigh*

2 comments:
I cannot reproduce this. I am on ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
Could it be affected by the fact that I'm on Mac OS X 10.6? Maybe the problem is deeper than ruby?
Post a Comment