Closed IFeelBloated closed 8 years ago
No particular reason, just tryna make things look pretty
The inner cast is inside an expression, so use a simpler C style cast to not make the expression look messy
The outside cast covers the whole expression up so use a C++ cast to make things clearer
I see. Anyway, I'd rather cast to int only the result of the right shift. That definitely fits in int. The result of the addition may not, and I want the sanitizer to catch that. Same for the other pull request.
Anyway, I'd rather cast to int only the result of the right shift.
done
a few more questions tho,
The sign bit is fine, because the compiler will generate an arithmetic right shift (x86 instruction sar
). This shifts in copies of the sign bit, not zero. It's not exactly the same as an integer division, but it's close enough. At least it's not completely wrong like a left shift of a negative value.
Anyway, this is more complicated than it needs to be and also I can't merge it anymore because of changes.
Why do you mix C and C++ casts?