Skip to content

MathUtils: make getMean()'s ternary unambiguous for an emulated double - #15947

Merged
ktf merged 2 commits into
AliceO2Group:devfrom
ktf:pr15947
Oct 12, 2026
Merged

ktf merged 2 commits into
AliceO2Group:devfrom
ktf:pr15947

Conversation

@ktf

@ktf ktf commented Oct 12, 2026

Copy link
Copy Markdown
Member

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.

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.
@ktf
ktf requested a review from shahor02 as a code owner October 12, 2026 14:56
Comment thread Common/MathUtils/include/MathUtils/detail/StatAccumulator.h Outdated
@ktf
ktf merged commit f642553 into AliceO2Group:dev Oct 12, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants