On Sunday, October 12th, 2025 at 11:48 AM, Michel Morin <mimomorin@gmail.com> wrote:
That's not what {} does by convention. It should output shortest
roundtrip.
That probably means round-tripping of values (i.e. ignoring cohorts). It would be nice to support a cohort-aware formatter. For example, "%Da" in C23 printf provides a round-trip representation that distinguishes cohorts (though not the shortest one).
Another cohort-related topic: Finite values have cohorts. Additionally, zero has both +0 and -0, and infinity has multiple bit representations. So we cannot hash decimal FP numbers simply by delegating to hash functions for unsigned integer types. We may need to canonicalize numbers before hashing.
In the general case should an entire equivalence class hash to the same value? I think no. Hash functions are designed to operate on bytes, and the members of an equivalence class are not bit-wise equal. We offer a normalization function[1] for those that would want to remove these effects[2]. Matt [1] https://develop.decimal.cpp.al/decimal/cmath.html#cmath_normalize [2] https://en.wikipedia.org/wiki/Hash_function#Data_normalization