Hi, I need in a loop to rest of division; which one is more efficient?
Qt Code:
for (i =0; .....i++) { //int r; //Math.DivRem(i+1, 2, out r); int r = (i + 1) % 2; if ( r == 0) return i; }To copy to clipboard, switch view to plain text mode
Hi, I need in a loop to rest of division; which one is more efficient?
Qt Code:
for (i =0; .....i++) { //int r; //Math.DivRem(i+1, 2, out r); int r = (i + 1) % 2; if ( r == 0) return i; }To copy to clipboard, switch view to plain text mode
Regards
According to the docs DivRem() calculated both the quotient and remainder.
If you need only the remainder use %, as division is the most time consuming from all of the basic arithmetic operators.
Bookmarks