On Sun, 28 Dec 2003 04:26:25 +0000, stau <st**@pretogal.pt> wrote in

comp.lang.c:

Hi!

I'm reading a C book, and it says that fmod() returns the remainder of the

exact division of it's arguments. Well, in a exact division, the remainder

shall always be 0 (zero), so this don't make any logic (I guess).

Anyway, foward in the chapter it says that fmod returns the remainder of

the integer division of it's arguments. I checked KnR 2nd ed. and the

man page, and still can't figure out wich one is correct.

Here is how the C standard defines it:

========

7.12.10.1 The fmod functions

Synopsis

1 #include <math.h>

double fmod(double x, double y);

2 The fmod functions compute the floating-point remainder of x/y.

Returns

3 The fmod functions return the value x - ny, for some integer n such

that, if y is nonzero, the result has the same sign as x and magnitude

less than the magnitude of y. If y is zero, whether a domain error

occurs or the fmod functions return zero is implementation defined.

========

No use is made of the word "exact".

--

Jack Klein

Home:

http://JK-Technology.Com
FAQs for

comp.lang.c

http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++

http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++

ftp://snurse-l.org/pub/acllc-c++/faq