Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Numeric validator precision/scale validation fails for certain floats on MRI 1.9.3 #51

@ashervb

Description

@ashervb

In validators/numeric_validator.rb on line 38

      def value_as_string(value)
        case value
          # Avoid Scientific Notation in Float to_s
          when Float      then value.to_d.to_s('F')
          when BigDecimal then value.to_s('F')
          else value.to_s
        end
      end

Given: f=-75.6942185

We call, f.to_d.to_s('F')

On all rubies except 1.9.3 we get:

"-75.6942185"

On MRI 1.9.3 we get:

"-75.69421850000001"

When then causes the validator to report an invalid precision/scale

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions