This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16850] modulo - feature or bug?
- From: "segher at kernel dot crashing dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Aug 2004 09:15:28 -0000
- Subject: [Bug c/16850] modulo - feature or bug?
- References: <20040801133528.16850.szak@gmx.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From segher at kernel dot crashing dot org 2004-08-24 09:15 -------
Subject: Re: modulo - feature or bug?
> For the scientific modulo the integer() function yields the lower
> bound integer of the float argument. In C it appears that integer(f)
> always equals integer(abs(f)). As a consequence, C modulo's integer
> function does not fulfil the equation
>
> integer(f+n) = integer(f) + n
> n := any integer
>
> for every f while n!=0. That's bad ground for algebra!
On the bright side, the equation
int(a/b + n) = int(a/b) + n
works fine for all a, b, n where a/b is defined in the
algebraic sense (and note we're talking integers here).
"Computer division" has nothing to do with algebraic
division (well, not very much, anyway). Better get
used to it :-)
Segher
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16850