I AM GETTING SOME DATA FROM TEMPERATURE SENSOR. IT IS A DOUBLE DATA TYPE. IS IT POSSIBLE TO CHANGE IT TO LONG OR INT DATA. AND JUST KEEP THE INTEGER PARTS. THX
1. Disable your CAPS LOCK! 2. Yes. If you really get the value as a Keil-supported floating point value then you should need only cast the float type to an int type. E.g.
float tempSensorValue = readTempSensor() /* ??? */; int integer = (int) tempSensorValue; unsigned int fraction = (unsigned int) (1000 * (tempSensorValue - integer)); printf("Result is %d.%u\n", integer, fraction);
View all questions in Keil forum