I'm learning about type conversion /type casting in C I have this code:
#include <stdio.h>
void main()
{
float x=1.2;
//Type conversion in c
float conv=x+'a';
printf("conv=%f",conv);
}
I now 'a' is equal to int 97, and in the line x+'a' there is an implicit/compilator conversion so now i have x+97.000...(idk how many zeros)
But the output is:
conv=98.199997
So I have two questions, the first one is, why the result is not 98.2 exactly?
and my other question is, how can I generate exact arithmetic operations? I have to round the result? or which is the best way?
Sorry for my English.