Hacker News new | ask | show | jobs
by Ericson2314 3716 days ago
> Decimal maintains precision: -0. != -0.0

What? This means their "arbitrary-precision decimals" are actually isomorphic to (Rational x Natural).

2 comments

The use of != there is very confusing but what they mean is stores a precision along each number, not that -0 != -0.0

e.g. in Python:

    >>> from decimal import Decimal as D
    >>> 2 * D("1.0")
    Decimal('2.0')

    >>> 2 * D("1.000")
    Decimal('2.000')

    >>> D("1.0") == D("1.000")
    True
That just means == is a "lossy" equivalence relation. I rather the precision be truely observable----every number is "infinite precision". Once can always include natural as extra field if one cares about empirical precision.
I'm having a bit of trouble parsing this, but Ion decimal values are not "infinite precision". Every decimal has a very specific, finite precision. It's a standard "coefficient and exponent" model, with no specification-enforced limit on either.
The idea is each number is adequately precise in that additional precision would mean additional useless trailing zeros.
The "!=" means "not the same value according to the Ion data model".

The Ion value 0.0 has one digit of precision (after the decimal point), while the value 0.00 has two. In the Ion data model, those are two distinct values, and conforming implementations must maintain the distinction.