View previous topic :: View next topic |
Author |
Message |
valemike Guest
|
simple float and int arithmetic... |
Posted: Thu Mar 25, 2004 11:45 am |
|
|
suppose i have:
Code: | int delta_y;
float slope;
...
delta_y = 0x4D; /* this is decimal 77 */
slope = (float) delta_y / 50.0; |
Using MPLAB's IDE for debugging, I find that my slope ends up equaling:
-3.773486e-005 ????
I expect it to look more like 77/50 = 1.54
Can someone shed some light how to get my desired 1.54 answer? Perhaps i'm not even expressing it the correct way and that's why i'm getting an error.
-Mike |
|
 |
valemike Guest
|
Found the Problem |
Posted: Thu Mar 25, 2004 12:36 pm |
|
|
Looks like Microchip's MPLAB doesn't interpret correctly the way that CCS stores floats. I did a printf() instead and all is fine. |
|
 |
dilandau
Joined: 25 Aug 2010 Posts: 11
|
|
 |
|