HI,
I´m working with a nokia 5110 lcd, I´m implementing a function for draw a line between 2 points.
The problem is that when I tried a division the result only shows the integer part.
This is the code:
void drawLine(char initX,char initY,char endX, char endY) {
char y;
float m=0;
int diffY,diffX;
printf("A) initX: %u initY: %u endX: %u endY: %u\n",initX,initY,endX,endY);
//slope is calculated
m=(float)((endY-initY)/(endX-initX));
printf("B) CEIL m: %f initX: %u initY: %u endX: %u end Y: %u \n",ceil(m),initX,initY,endX, endY);
printf("C) FLOOR m: %f initX: %u initY: %u endX: %u end Y: %u \n",floor(m),initX,initY,endX, endY);
.
.
.
}
the result is
A) initX: 1 initY: 1 endX: 7 endY: 47
B) CEIL m: 7.000000 initX: 1 initY: 1 endX: 7 end Y: 47
C) FLOOR m: 7.000000 initX: 1 initY: 1 endX: 7 end Y: 47
the rigth result in m is 7.66, but B) and C) show 7.00000.
I don´t know if the problem is the diuvision or the data type(%f) declared in printf.
If someone can help I will really apreciate it.
Thanks in advance.
HI,
I´m working with a nokia 5110 lcd, I´m implementing a function for draw a line between 2 points.
The problem is that when I tried a division the result only shows the integer part.
This is the code:
the result is
the rigth result in m is 7.66, but B) and C) show 7.00000.
I don´t know if the problem is the diuvision or the data type(%f) declared in printf.
If someone can help I will really apreciate it.
Thanks in advance.