What is the difference between System.Math.DivRem() and the % operator?
What is the difference between System.Math.DivRem() and the % operator?
Share
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.
%gives you the remainder of a division and discards the quotient altogether, whileDivRem()calculates and returns both the quotient and the remainder.If you’re only concerned about the remainder of a division between two integers, use
%:If you need to know how many times 10 was divided by 3 before having a remainder of 1, use
DivRem(), which returns the quotient and stores the remainder in an out parameter: