Hi
I have (I think) a simple problem. I am using the C18 compiler to write code to be used on a pic 18f4620 but at the moment am only compiling the code and running it with MPSIM.
I need to divide 2 numbers , which will result in a floating point number. However when I try this with the following code and watch variable j it returns a value of 2.0, not 2.5.
double j;
unsigned char i, Byte0, Byte1, Byte2, Byte3, x, y, z;
unsigned long FTW, bit32, Fo, Fref;
void main (void)
{
y=5;
z=2;
j=y/z;
}
I obviously do not understand the way floats are used in Microchip C.
Could somebody give me some advise please?
Thanks
I have (I think) a simple problem. I am using the C18 compiler to write code to be used on a pic 18f4620 but at the moment am only compiling the code and running it with MPSIM.
I need to divide 2 numbers , which will result in a floating point number. However when I try this with the following code and watch variable j it returns a value of 2.0, not 2.5.
double j;
unsigned char i, Byte0, Byte1, Byte2, Byte3, x, y, z;
unsigned long FTW, bit32, Fo, Fref;
void main (void)
{
y=5;
z=2;
j=y/z;
}
I obviously do not understand the way floats are used in Microchip C.
Could somebody give me some advise please?
Thanks