Mail Archives: djgpp/1998/04/16/16:16:32
>When the index is outside the buffersize the code should read the next block
>from the file and continue. To do this I'm using the modulo operator but there
>seems a bug with this.
>
>bl = BufLen % i;
>
>gives following results:
Why would you do mod 1? you can't get a remainder... unless this is just a
demonstration
>BufLen = 4096
>i = 1
>bl = 0
>
The number is even, so this is OK...
>i = 2
>bl = 0
>
4096/3=1365.3333333 and that 333333 is 1/3. Thus, the answer is one. This isn't
a bug. It's suppose to do that.
>bl = 1 ???????
>
>All variables are unsigned long
>
>I just checked the code and substituted "bl = BufLen % i" with "bl = i /
BufLen"
>and this works fine.
These are 2 different things. Using any numbers that are non-decimal, the
computer will ALWAYS round down. Even if it's 1.987, it's 1. Mod is what the
remainder would be if you treated it like a division question like you did in
grade 3 when decimals were too hard. 42/5= 8 Remainder 2. Thus, 42%5=2.
--
"DeHackEd"
EMail address not given out due to low-life spammers.
- Raw text -