Project

General

Profile

Bug #13833

String#scanf("%a") incorrectly requires a sign on the (binary) exponent

Added by cabo (Carsten Bormann) 3 months ago. Updated 30 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
[ruby-core:82435]

Description

>> Float("0x1p9")
=> 512.0
>> Float("0x1p+9")
=> 512.0
>> "0x1p+9".scanf("%a")
=> [512.0]
>> "0x1p9".scanf("%a")
=> [0.0]                              # Oops
>> RUBY_VERSION
=> "2.4.1"

In scanf.rb, there are three regexps that say the equivalent of [pP][+-] where they should say [pP][+-]?

Associated revisions

Revision 60261
Added by nobu (Nobuyoshi Nakada) 30 days ago

Fix bug about String#scanf("%a")

  • lib/scanf.rb (extract_float, initialize): allow to omit a sign on the binary exponent. [Bug #13833] [Fix GH-1689]

From: tarotaro0 tarousann11922960@yahoo.co.jp

History

#1 [ruby-core:82568] Updated by tarotaro0 (kodai nakamura) 3 months ago

Hi, cabo.

I implemented to fix this bug and created PR:

https://github.com/ruby/ruby/pull/1689

Could you please check this?

#2 Updated by nobu (Nobuyoshi Nakada) 30 days ago

  • Status changed from Open to Closed

Applied in changeset trunk|r60261.


Fix bug about String#scanf("%a")

  • lib/scanf.rb (extract_float, initialize): allow to omit a sign on the binary exponent. [Bug #13833] [Fix GH-1689]

From: tarotaro0 tarousann11922960@yahoo.co.jp

Also available in: Atom PDF