Skip to content

How should rounding errors in step constraint validation be treated? #5207

Open
@teapotd

Description

@teapotd

Spec for step constraint validation says:

Constraint validation: When the element has an allowed value step, and the result of applying the algorithm to convert a string to a number to the string given by the element's value is a number, and that number subtracted from the step base is not an integral multiple of the allowed value step, the element is suffering from a step mismatch.

input[type=number]'s algorithm to convert a string to a number follows rules for parsing floating-point number values which specifically mention rounding to IEEE 754 double-precision float:

  1. Conversion: Let S be the set of finite IEEE 754 double-precision floating-point values except −0, but with two special values added: 2^1024 and −2^1024.
  2. Let rounded-value be the number in S that is closest to value, selecting the number with an even significand if there are two equally close values. (The two special values 2^1024 and −2^1024 are considered to have even significands for this purpose.)
  3. If rounded-value is 2^1024 or −2^1024, return an error.
  4. Return rounded-value.

step attribute value is also parsed using these steps. It implies that step mismatch check should check if one base-2 floating-point number is exact integer multiple of another, which doesn't make much sense in practice.

Firefox and Chrome use decimal floating-point numbers instead to avoid rounding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatStandard is not web compatible or proprietary feature needs standardizingtopic: forms

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions