0.01.to_s -> "1.0"

Hi,

I located very strange behavior of float under Linux. 0.123 is converted
to 123.0
under windows 0.123 is converted correctly to 0.123.

Here is samples:

ruby -v
ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-linux]

irb
irb(main):001:0> 0.123.to_s
=> “123.0”

C:>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
C:>irb
irb(main):001:0> 0.123.to_s
=> “0.123”

How to receive correct float under Linux. Please advice.

Thank you.
Andriy.

On Sat, Oct 3, 2009 at 6:35 PM, Andriy T. [email protected]
wrote:

ruby -v
ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-linux]

irb
irb(main):001:0> 0.123.to_s
=> “123.0”
How to receive correct float under Linux. Please advice.

That is known bug http://redmine.ruby-lang.org/issues/show/1735

to fix gcc 4.4 optimization, use CFLAGS -fno-strict-aliasing

Nikolai L. wrote:

On Sat, Oct 3, 2009 at 6:35 PM, Andriy T. [email protected]
wrote:

ruby -v
ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-linux]

irb
irb(main):001:0> 0.123.to_s
=> “123.0”
How to receive correct float under Linux. Please advice.

That is known bug http://redmine.ruby-lang.org/issues/show/1735

to fix gcc 4.4 optimization, use CFLAGS -fno-strict-aliasing

Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs