Skip to content

Conversation

adienes
Copy link
Member

@adienes adienes commented Jul 3, 2025

as written it's incorrect since sum will promote the types but + (and dot) overflow

julia> x = collect(0xf0:0xff); y = copy(x);

julia> sum(dot(i, j) for (i, j) in zip(x, y))
0x00000000000004d8

julia> dot(x, y)
0xd8

closes #1453

@stevengj
Copy link
Member

stevengj commented Jul 3, 2025

Should we instead fix the code to match the docstring?

@adienes
Copy link
Member Author

adienes commented Jul 3, 2025

I suppose that depends on whether you think of dot more as a reducing operation or a "scalar" operation on scalars-that-are-actually-vectors, in that reducing operations typically widen types and arithmetic does not.

note that numpy also chooses to overflow on np.dot (so Julia and numpy are at the moment consistent)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dot overflows

2 participants