- Where Developers Learn, Share, & Build Careers
Has anyone solved this problem in Ruby:
We say that: a = 8.1999999
We wanted to score it by two decimals which is 8.20 and it has increased to 1,000,000 to 8,200,000
We do it like this;
(a (2) * 1000000) .to_i But we have 8199999, why?
There are things dentic, if we multiply, we get the right result 1000, 100000 or 10000000, but not 1000000. Do you know any body?
We are using 1.9.2 ruby and try with 1.9.3 also.
Thank you! is required 'big decimental' A = budicamcam (8.1999999.to_s) (a.round (2) * 1000000) .to_i
Comments
Post a Comment