Yes, I understand the purpose of the 368 offset. However, since you are getting -64 it appears that the offset should be 304 instead. I was just trying to explain why you are getting a value of -64.
How do you implement getting the integer part of a decimal, and the fractional part of a decimal?
I'm not sure if this is what you want, but here's one way using simpleide:
#include "simpletools.h" // Include simple tools
int main()
{
int aninteger;
float afloat1, adecpart;
afloat1 = 27.4; // separate this float into its int and dec parts
aninteger = (int)afloat1;
adecpart = afloat1 - aninteger;
print("%f, %d, %f \n", afloat1, aninteger, adecpart);
}
afloat1 is the float value to separate into its integer and decimal parts
aninteger is the integer part
adecpart is the decimal part (as a decimal). If you want to make it an integer you would have to multiply it by 10 to the number of places you want to have.
One issue will be how the decimal value of a float is represented. For example 0.4 when multiplied by 1000 will print as 399. Converting 27.45 will result in 27, 0.45001, and if multiplied by 1000 will print the decimal part as 450.000763
Comments
Thanks for your help Dave
I'm not sure if this is what you want, but here's one way using simpleide: afloat1 is the float value to separate into its integer and decimal parts
aninteger is the integer part
adecpart is the decimal part (as a decimal). If you want to make it an integer you would have to multiply it by 10 to the number of places you want to have.
One issue will be how the decimal value of a float is represented. For example 0.4 when multiplied by 1000 will print as 399. Converting 27.45 will result in 27, 0.45001, and if multiplied by 1000 will print the decimal part as 450.000763
Tom