News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

### Author Topic: How do you calculate a modulus out of an offset?  (Read 1933 times)

#### Pikachumanson

• Hero Member
• Posts: 607
##### How do you calculate a modulus out of an offset?
« on: November 06, 2012, 01:23:21 am »
I've seen 4000 used to calculate the modulo off of something like 3B77
But what if the number is low like 3C7 do i still use 4000 or does the number differ depending on which rom bank you are on?

#### Malias

• Sr. Member
• Posts: 303
##### Re: How do you calculate a modulus out of an offset?
« Reply #1 on: November 06, 2012, 02:09:21 am »
Actually, taking the modulus 4000 of either of those numbers wouldn't change their value.  Could you be a little more specific?
The great achievement is to lose one's reason for no reason, and to let my lady know that if I can do this without cause, what should I do if there were cause?
~Don Quixote~

#### KC

• Full Member
• Posts: 210
##### Re: How do you calculate a modulus out of an offset?
« Reply #2 on: November 06, 2012, 01:16:53 pm »
The modulo returns the remainder of a division. For example, 0x3C7 mod 0x4000 = 0x3C7, because 0x3C7 / 0x4000 = 0 with the remainder of 0x3C7. 0x43C7 mod 0x4000 = 0x3C7, because 0x43C7 / 0x4000 = 1 with the remainder of 0x3C7.
You don't have to adapt the modulo to your number, but to the task you want to accomplish. In your case, you probably want to calculate the offset into a ROM bank. The modulo number shouldn't change for that.

#### Pikachumanson

• Hero Member
• Posts: 607
##### Re: How do you calculate a modulus out of an offset?
« Reply #3 on: November 06, 2012, 02:46:14 pm »
Thanks for clearing that up for me!