3 ms·
In both cases the mistake happened when two 16-bit integers were multiplied and the result was truncated when stored to a 16-bit number. This is the point at wh
by saurik 11y ago
In both cases the mistake happened when two 16-bit integers were multiplied and the result was truncated when stored to a 16-bit number. This is the point at which the information was lost, and this is the point that with different tradeoffs (note: I am not advocating for these alternatives) would either result in a 32-bit number or a runtime overflow check, leading there to no longer be a bug. The same bug would exist with a fully generic function, or even without a function at all. Passing a number that has already been truncated to a function that could have accepted a wider number is not a bug: the bug already happened.