Bug #2792

String#to_f on Ruby-1.8.6-p399

Added by Masao Mutoh almost 2 years ago. Updated 10 months ago.

[ruby-dev:40487]
Status:Third Party's Issue Start date:02/25/2010
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
ruby -v:ruby 1.8.6 (2010-02-05 patchlevel 399) [x86_64-linux]

Description

Ruby-1.8.6のString#to_fで、小数点の扱いがおかしいようです。

% ruby -v -e 'p "0.7".to_f'
ruby 1.8.6 (2010-02-05 patchlevel 399) [x86_64-linux]
7.0

% ruby -v -e 'p "0.7".to_f'
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
0.7

History

Updated by Run Paint Run Run almost 2 years ago

I suspect I'm seeing a symptom of the same problem. Just installed "ruby 1.8.6 (2010-03-05 patchlevel 400) [i686-linux]" from source, and found floats to be horribly broken. 

  >> 1.3.to_int
  => 13
  >> irb(main):002:0> 1.3.ceil
  => 13
  >> irb(main):003:0> 2 + 0.5
  => 7.0

Am I missing a dependency or is this a regression?

Updated by Yusuke Endoh almost 2 years ago

遠藤です。

> Ruby-1.8.6のString#to_fで、小数点の扱いがおかしいようです。
>
> % ruby -v -e 'p "0.7".to_f'
> ruby 1.8.6 (2010-02-05 patchlevel 399) [x86_64-linux]
> 7.0

gcc 4.4.1 を使っていませんか?
[ruby-core:26937] [ruby-core:28037] で同様の報告があり、
gcc 4.4.1 のバグのせいではないかということです。

gcc 4.3 か gcc 4.4.2 なら大丈夫だそうです。

-- 
Yusuke ENDOH <mame@tsg.ne.jp>

Updated by Run Paint Run Run almost 2 years ago

Bah. I'd missed that thread. Thanks, Yusuke.

Updated by Marc-Andre Lafortune almost 2 years ago

  • Status changed from Open to Third Party's Issue

Also available in: Atom PDF