3 ms·
a total ordering doesn't necessarily carry any semantic meaning and is not really what we care about here. We want semantically important ranges, to be able to
by dnautics 5y ago
a total ordering doesn't necessarily carry any semantic meaning and is not really what we care about here. We want semantically important ranges, to be able to check domains and ranges of float-valued functions (for example, arcsin, arccos, 1/x, etc.)
- charcircuit 5y ago>and is not really what we care about here For a set to have a range that set must have a total order defined. If we want to find the range of a datatype we need to have a total ordering of all the possible values of that datatype. Total ordering is very relevant to the question at hand.
- dnautics 5y agoyes, total ordering the concept is relevant, but any given total order is not necessarily relevant. You could make a total order that goes 0.0, 1.0, 0.5, 0.75, 0.33, 0.56, 0.77, ... and that would NOT be useful for ranges. In particular, the using IEEE order and building a range contaning NaNs is not semantically useful. Another detail is the distinction between -0.0 and 0.0; if you naively use the IEEE ordering to construct a type system you will have some problems with for example clopen ranges (-0.0, 0.0] and [-0.0, 0.0)
- charcircuit 5y agoThere shouldn't be any problems when using the total order from the standard as it defines -0 < 0 to be true. I don't see how there's a problem with a range containing NaN. It's no weirder than a range containing infinity.
- sharikous 5y agoIt defines also -0 == 0 and NaN != NaN. That's alone makes it rather weird
- colejohnson66 5y agoWhy is defining negative zero equal to positive zero confusing? Because -0 < 0? That's to ensure there's total ordering - if they're equal (but not "identical"), you need some definition on ordering them. I can understand the confusion many have with NaN, but the idea is that it's not a number, so it's not equal to anything in a number-like type.
- jjgreen 5y agohypot(Inf, NaN) == Inf suggests otherwise.
- dnautics 5y agoRight. I guess you didn't see that those two clopen intervals are mathematically identical, even though they are representationally unequal.
- hvdijk 5y agoThe post mentions from_chars specifically, and the quote about the range is about that function. That means we need to ask the question whether NaN is "in the range representable by the type of value" too. For most other functions I would agree with you as NaN would be called out as a special case, and we have a meaningful range for all non-NaN values, but for from_chars I do not think "semantically important ranges" gets us there.