Skip to content

Use xsd:decimal instead of xsd:float #77

@jmkeil

Description

@jmkeil

Hi. In units.ttl, constants.ttl, prefixes.ttl there are some numbers with the datatype xsd:float. The accuracy of the values intended to represent is impaired by the use of xsd:float, as by definition the semantically represented value is a value, that can be represented with a IEEE 754 32 bit binary floating point number. Literals with lexical representations that do not exactly match a 32 bit binary floating point number are rounded. Following, the lexical representation suggests an accuracy that is not given. For example,

  • "1e-06"^^xsd:float represents 0.0000009999999974752427078783512115478515625,
  • "1e+30"^^xsd:float represents 1.000000015047466219876689E+30, or
  • "0.0174532925199433"^^xsd:float represents 0.01745329238474369049072265625.

For xsd:float, only the first 7 digits are guaranteed (16 digits in case of xsd:double). Instead, xsd:decimal should be used, as it preserves arbitrary precision. xsd:decimal has the disadvantage to not permit exponential notation. But I think, preserving the accuracy of the numbers is of highest importance for the SI Reference Point, so this disadvantage is acceptable. Using xsd:decimal would also permit to use Turtle shorthand syntax for decimal numbers. Further, as xsd:integer is a subtype of xsd:decimal properties with Integer and Decimal Number values, could get the rdfs:range xsd:decimal, in contrast to xsd:float and xsd:integer that are not in a subtype relation to each other.

Related issue: #24 (@stuchalk), #59
Detailed discussion of the problem: https://doi.org/10.1007/978-3-031-06981-9_10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions