FMOD function

Hello, I used the fmod function and I am confuse about the result.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Sequencia ij 4

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main () {
	double i=0, j=1, n=1;

	while (i<=2) {
		if (fmod(i,1) == 0 && fmod(j,1) == 0)
			printf ("I=%.0lf J=%.0lf\n", i, j);
		else if  (fmod(j,1) == 0 && fmod(i,1) != 0) 
			printf ("I=%.0lf J=%.1lf\n", i, j);
		else if (fmod(i,1) == 0 && fmod(j,1) != 0)
			printf ("I=%.0lf J=%.1lf\n", i, j);	
		else 
			printf ("I=%.1lf J=%.1lf\n", i, j);
		j+=1;
		if (j>n+2) {
			n+=0.2;
			j=n;
			i+=0.2;
		} 
	}

	return 0;
}


Porém a saída é a seguite:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
I=0 J=1
I=0 J=2
I=0 J=3
I=0.2 J=1.2
I=0.2 J=2.2
I=0.2 J=3.2
I=0.4 J=1.4
I=0.4 J=2.4
I=0.4 J=3.4
I=0.6 J=1.6
I=0.6 J=2.6
I=0.6 J=3.6
I=0.8 J=1.8
I=0.8 J=2.8
I=0.8 J=3.8
I=1 J=2.0
I=1 J=3
I=1 J=4
I=1.2 J=2.2
I=1.2 J=3.2
I=1.2 J=4.2
I=1.4 J=2.4
I=1.4 J=3.4
I=1.4 J=4.4
I=1.6 J=2.6
I=1.6 J=3.6
I=1.6 J=4.6
I=1.8 J=2.8
I=1.8 J=3.8
I=1.8 J=4.8
I=2.0 J=3.0
I=2 J=4.0
I=2 J=5.0


Não entendi o porque :
I=1 J=2.0
I=1 J=3
I=1 J=4
Sendo que:
fmod(numer, denom) -- http://www.cplusplus.com/reference/cmath/fmod/

fmod = numer - tquot * denom

tquot = numer/denom

Nesta sequencia J tem o valor de 2.0000 entao:

fmod = 2 - (2/1) * 1 = 0

Pq esta resultando fmod = 1?

Pelo que eu entendi, deveria ser 0.
Alguem pode me ajudar.
Obrigada.
> Pq esta resultando fmod = 1?
fmod no es 1, `i' es 1
Topic archived. No new replies allowed.