Repository navigation
Commit f642553
MathUtils: make getMean()'s ternary unambiguous for an emulated double (#15947)
On Metal the double keyword names a class that converts to float and back
implicitly, so the conditional operator has to form an implicit conversion
sequence from each arm to the type of the other. Both directions succeed and the
standard has no tie-break, which makes wsum > 0. ? sum / wsum : 0. ill-formed
there. With a builtin double the arms go through the usual arithmetic
conversions instead, and those are ranked, so nothing has to be resolved.
double{} gives both arms the declared type on every backend: zero for the
builtin, and, since the emulated type's default constructor is not user-provided,
an all-bits-zero +0.0 on Metal.
Co-authored-by: David Rohr <github@jwdt.org>1 parent b45ab11 commit f642553
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments