Hi,
I found a weird problem.
In ruby 1.8.5, I get the following result in irb.
BigDecimal.new(“86.02”).to_f #=> 86.2
I don’t know if this is a ruby bug or machine bug.
In ruby 1.8.6 on a different machine, it’s ok.
Is this a known issue?
Sam
Hi,
I found a weird problem.
In ruby 1.8.5, I get the following result in irb.
BigDecimal.new(“86.02”).to_f #=> 86.2
I don’t know if this is a ruby bug or machine bug.
In ruby 1.8.6 on a different machine, it’s ok.
Is this a known issue?
Sam
On Oct 5, 1:02 pm, Sam K. [email protected] wrote:
Is this a known issue?
Sam
I narrowed down the problem.
It has nothing to do with converting to float.
irb(main):023:0> BigDecimal.new(“1.0234”)
=> #BigDecimal:b7efb05c,‘0.1234E1’,8(12)
The internal representation is wrong.
Will upgrading ruby fix this problem?
On Mon, Oct 5, 2009 at 2:05 PM, Sam K. [email protected] wrote:
Is this a known issue?
You don’t say what patch level of 1.8.5 you are on. Using 1.8.5pl114
it works fine. However, likely it is a bug where the 0s immediately
following the decimal get eaten.
Upgrade your Ruby. Don’t use 1.8.5.
Kirk H.
On Mon, Oct 5, 2009 at 1:15 PM, Sam K. [email protected] wrote:
In ruby 1.8.6 on a different machine, it’s ok.
The internal representation is wrong.
Will upgrading ruby fix this problem?
I suspect so:
christopher@ubuntu:~$ ruby -v -rbigdecimal -e
‘d=BigDecimal.new(“1.0234”); p d; p d.to_f’
ruby 1.8.6 (2009-08-04 patchlevel 383) [x86_64-linux]
#BigDecimal:7ff22e270380,‘0.10234E1’,18(18)
1.0234
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs