microbiomedata / nmdc-schema

National Microbiome Data Collaborative (NMDC) unified data model
https://microbiomedata.github.io/nmdc-schema/
Creative Commons Zero v1.0 Universal
27 stars 8 forks source link

QuantityValue.slot_usage.has_numeric_value.range: Float -> Double #1904

Open turbomam opened 5 months ago

turbomam commented 5 months ago

We just have to pick one here

turbomam commented 5 months ago

According to Claude:

The main differences between an XSD (XML Schema Definition) float and double are:

  1. Precision:

    • float: An XSD float is a single-precision 32-bit floating-point number. It has a precision of approximately 7 decimal digits.
    • double: An XSD double is a double-precision 64-bit floating-point number. It has a precision of approximately 15 decimal digits.
  2. Range:

    • float: The range of values that can be represented by an XSD float is approximately ±3.4 × 10^-38 to ±3.4 × 10^38.
    • double: The range of values that can be represented by an XSD double is approximately ±1.7 × 10^-308 to ±1.7 × 10^308.
  3. Memory Usage:

    • float: An XSD float occupies 4 bytes of memory.
    • double: An XSD double occupies 8 bytes of memory.
  4. Accuracy:

    • float: XSD floats are less accurate compared to doubles due to their lower precision. They are more prone to rounding errors and may not be suitable for computations that require high accuracy.
    • double: XSD doubles provide higher accuracy and are suitable for most numerical computations that require precision.

In summary, XSD doubles have higher precision, a wider range of representable values, and occupy more memory compared to XSD floats. Doubles are generally preferred when precision is important, while floats can be used when memory is a constraint, and the required range and precision are within the limits of a single-precision floating-point number.

It's important to note that both XSD floats and doubles follow the IEEE 754 standard for floating-point arithmetic, which defines their representation and behavior.

turbomam commented 5 months ago

I don't see why we need double here

turbomam commented 3 months ago

^ I guess I was thinking in terms of huge ranges at the cost of memory footprint

there was also some discussion about using decimal

does one of those preserve prettier/more faithful string representations?