On Wed Sep 13 09:01:07 2023 +0000, Giovanni Mascellani wrote:
I guess this should be something like `dst->u[k].u = (src1->value.u[k].f != 0.0f) ? src2->value.u[k].u : src3->value.u[k].u`. In particular, the first operand should take the `float` value and compare it to `0.0f`, so that `-0.0f` is also considered equal to zero. The other two operands should take the unsigned part, so that there is no implicit cast when assigning to the destination's unsigned part. Same for the double below.
I stand corrected! The correct version is probably rather: `dst->u[k] = (src1->value.u[k].f != 0.0f) ? src2->value.u[k] : src3->value.u[k]`. IOW, we have to copy the `union`, not the unsigned field, because the data type of the second and third operand might be larger than an unsigned (i.e., it might be a double).
Also, similarly to other `fold_*()` helpers, you might assert that the type of the second and third operand coincides with the type of the result.