When I do, for example, -1 % 3, I expect the result to be 2.
When I execute the following TASM instructions I get an unexpected result:
mov ax, -1
xor bh, bh
mov bl, 3
idiv bl ; ah = FF (I expected 02), al = 00
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This web page states that:
Wikipedia has some information regarding pitfalls with a signed remainder.
A possible workaround could be to use
divinstead ofidiv, and/or keeping track of signs manually.