-
Notifications
You must be signed in to change notification settings - Fork 782
Description
[charconv.from.chars]/6.4 says:
In any case, the resulting value is one of at most two floating-point values closest to the value of the string matching the pattern.
This is ambiguous. It could mean either:
-
The resulting value is the implementation's choice of one of a set of values, and that set contains the two values closest to the value of the string.
-
The resulting value is the implementation's choice of one of a set of values, and that set contains all values that are closest to the value of the string (of which it turns out there can be up to two).
I think the normal English interpretation would be (1), but the intended interpretation is actually (2).
(Under (1), the string "1.0" can produce the value one ULP less than 1.0 or it can produce 1.0, and the string "1.00<lots of 0s>1" can produce those same two values, because the value one ULP less than 1.0 is closer to that string than the value one ULP greater than 1.0.)
Perhaps the wording from [conv.double]/2 and [expr.static.cast]/11 can be used instead:
If the source value can be exactly represented in the destination type, the result of the conversion is that exact representation. If the source value is between two adjacent destination values, the result of the conversion is an implementation-defined choice of either of those values.