• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

programming n00b

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Originally posted by: VirtualLarry
Originally posted by: DaveSimmons
> don't know what the remainder of 30-2 and 40 should be...
You don't understand the "mod" operator? That's not goovy.
Yes. That's one of the few things that I got wrong in an intro programming class in 'C' once.. forgot how the integral "mod" operator performed with negative values. (Not shown in the example.) Since I don't normally use it that way, I figure I'm safe.
Yes, I use mod on positive numbers fairly often, but I can't recall using it for anything allowed to be negative in literally the last decade. If I had to, I'd definitely RTFM myself to refresh my memory.
 
Originally posted by: Zanix
Originally posted by: DaveSimmons
> don't know what the remainder of 30-2 and 40 should be...

You don't understand the "mod" operator? That's not goovy.

You should also look up the precedence rules for your language to see whether you need to be computing
a. (40 % 28 ) /4
It's a. No I didn't understand the mod operator. It's called REM in MIPS and I wasn't sure if it was used the same.

Thanks for the help.
No problem, I was thinking C/C++ rather than assembly, but it should be exactly the same as integer mod operator in C, or rem / mod in other assembly languages.

All return the remainder after division, here (40 % 28) = 12. In really old CPUs like 6502 that lack REM you'd probably code this using a loop subtracting the divisor until the remainder is less than the divisor.

e.g. 40 % 9 :
40 - 9 = 31, - 9 = 22, - 9 = 13, -9 = 4 and stop since 4 < 9.



 
Originally posted by: DaveSimmons
Originally posted by: Zanix
Originally posted by: DaveSimmons
> don't know what the remainder of 30-2 and 40 should be...

You don't understand the "mod" operator? That's not goovy.

You should also look up the precedence rules for your language to see whether you need to be computing
a. (40 % 28 ) /4
It's a. No I didn't understand the mod operator. It's called REM in MIPS and I wasn't sure if it was used the same.

Thanks for the help.
No problem, I was thinking C/C++ rather than assembly, but it should be exactly the same as integer mod operator in C, or rem / mod in other assembly languages.

All return the remainder after division, here (40 % 28) = 12. In really old CPUs like 6502 that lack REM you'd probably code this using a loop subtracting the divisor until the remainder is less than the divisor.

e.g. 40 % 9 :
40 - 9 = 31, - 9 = 22, - 9 = 13, -9 = 4 and stop since 4 < 9.

You're alright DaveSimmons.

And you're good at math too. The gears in my head slip a bit when it comes to math.
 
Originally posted by: Zanix
Originally posted by: DaveSimmons
Originally posted by: Zanix
Originally posted by: DaveSimmons
> don't know what the remainder of 30-2 and 40 should be...

You don't understand the "mod" operator? That's not goovy.

You should also look up the precedence rules for your language to see whether you need to be computing
a. (40 % 28 ) /4
It's a. No I didn't understand the mod operator. It's called REM in MIPS and I wasn't sure if it was used the same.

Thanks for the help.
No problem, I was thinking C/C++ rather than assembly, but it should be exactly the same as integer mod operator in C, or rem / mod in other assembly languages.

All return the remainder after division, here (40 % 28) = 12. In really old CPUs like 6502 that lack REM you'd probably code this using a loop subtracting the divisor until the remainder is less than the divisor.

e.g. 40 % 9 :
40 - 9 = 31, - 9 = 22, - 9 = 13, -9 = 4 and stop since 4 < 9.

You're alright DaveSimmons.

And you're good at math too. The gears in my head slip a bit when it comes to math.

Man, you're lucky that you don't have only one Maths Gear in your head.

You're even luckier that it's not a reverse gear 😛 :beer:
 
Back
Top