Closed
Description
This surprised me:
julia> typeof(reduce(&, Int8(0), (Int8(4),)))
Int32
It makes sense of +
to widen the type to prevent overflow, but &
cannot overflow. I tried to counteract the automatic widening by providing an explicit neutral element, but that didn't help.
I also notice that a +
reduction widens Bool
to Int64
, while a &
reduction does not widen it.
Should there be a widereduce
in addition to reduce
?
Should there be an optional argument T
that lets people specify the return type?