Skip to content

Avoid floating-point number for @version #296

Closed
@lo48576

Description

@lo48576

The API provides an option for setting the processing mode to json-ld-1.0, which will prevent JSON-LD 1.1 features from being activated, or error if @version entry in a context is explicitly set to 1.1.

https://w3c.github.io/json-ld-syntax/#dfn-processing-mode

JSON-LD processors are required to check @version value if it is found at appropriate place, but floating-point number comparison is unnecessarily complex for this purpose.

IEEE 754 floating point number cannot represent exact 1.1, and programs may use various (not same) representation very close to 1.1 (but not exact 1.1).
This can make straightforward implementation (for example doing if (version == 1.1) { ... }) to fail checking version correctly.
To deal with this problem, processors are forced to compare values in complex way (such as if (version >= 1.1 - EPSILON && version <= 1.1 + EPSILON) { ... }).

JSON-LD version is neither a real number nor a floating-point number.
I think it should be string "1.1" or something exactly representable value, instead of floating-point number.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions