imul and idiv works exactly the same like mul and div. So is it just a convention to use it with signed integers?
Asked
Active
Viewed 44 times
0
phuclv
- 32,499
- 12
- 130
- 417
always_improve
- 11
- 3
-
4No, they don't work the same for signed values, so you should indeed be using them if that's your scenario. – 500 - Internal Server Error Jan 05 '22 at 10:45
-
3Note that what @500-InternalServerError says only applies to the one operand form of `imul` and `idiv`. The two and three operand forms of `imul` apply to signed and unsigned numbers equally. – fuz Jan 05 '22 at 11:04
-
`imul` and `mul` are not the same, and not only in signedness. See [this answer](https://stackoverflow.com/a/42589535/485343) for more details. – rustyx Jan 05 '22 at 11:15