Skip to content

Float() parsing innacuracy #6480

@mannreis

Description

@mannreis

Environment Information

I'm running jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 25.252-b09 on 1.8.0_252-b09 +jit [linux-x86_64] from logstash (although I don't think this is a logstash specific problem) on a Linux 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Here's a side-by-side comparison between ruby and jruby, I think the expected behavior should be the later:

  • ruby -e 'v="661e7086-33af-11eb-a4ef-fa163ec4aef9"; puts(Float(v) rescue v)' returns 661e7086-33af-11eb-a4ef-fa163ec4aef9
  • jruby -e 'v="661e7086-33af-11eb-a4ef-fa163ec4aef9"; puts(Float(v) rescue v)' returns Infinity

I think jruby is parsing "661e7086" from the original the string and interpreting as scientific notation. Although more robust, I don't think is a good behaviour in general (imho jruby should follow ruby).

Thanks a lot for the attention!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions