Int to float

I try to convert int to float and be able to see the extra 00.0043534 digits
but then i convert the int to float the float still remain int and i got as output
1.0000 and 2.000..

code:

int x =10564;
float xp;

xp = x / 654;   // 10564 / 654 = 16.1529

File dataFile = SD.open("datalog.txt", FILE_WRITE);

if (dataFile){
dataFile.println(xp, 4);
dataFile.close();

10564 / 654 = 16.1529 but what i get as output is 16.0000

is that because of the dataloger? or i do something wrong?

Try this instead:

xp = x / 654.0; // the decimal point forces floating-point arithmetic

Crazy float :smiley:
I remember in C/C++ programming there wasn't that kind of problem.

It's working, thanks.

I remember in C/C++ programming there wasn't that kind of problem.

You are still using C/C++, and yes, using integer arithmetic and expecting floating point results was stupid then, too.