delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/16/16:16:32

From: "DeHackEd" <Not DOT given AT out>
References: <35360BD4 DOT 5DB6C8C5 AT sis DOT co DOT at>
Subject: Re: Bug in gcc 2.7.2?
Date: Thu, 16 Apr 1998 16:12:20 -0400
Lines: 48
Message-ID: <#KzQZPXa9GA.234@uppubnews03>
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019