B
bala.pandu
Hello Everyone,
When i am assigning a float value and try to print the same,
i found the value stored is not the exact value which i gave.
int main()
{
float f1;
printf("Enter a float value : \n");
scanf("%f",&f1);
printf ("float value entered is : %f\n",f1);
}
if i give 22.2 as input, i am getting 22.200001 as output.
if i give 22.22 as input, i am getting 22.219999 as ouput.
but i want 22.200000 and 22.220000 as output.
is there anyway to do it.
P.S : The above is not true for all the values. for example
if i give 22.1 i am getting 22.100000
is there anyway to do it.
Thanks and Regards,
P.Balaji
P.S : The above is not true for all the values. for example
if i give 22.1 i am getting 22.100000. And if i use double instead of
float, i can get the desired result but i want to use only float.
When i am assigning a float value and try to print the same,
i found the value stored is not the exact value which i gave.
int main()
{
float f1;
printf("Enter a float value : \n");
scanf("%f",&f1);
printf ("float value entered is : %f\n",f1);
}
if i give 22.2 as input, i am getting 22.200001 as output.
if i give 22.22 as input, i am getting 22.219999 as ouput.
but i want 22.200000 and 22.220000 as output.
is there anyway to do it.
P.S : The above is not true for all the values. for example
if i give 22.1 i am getting 22.100000
is there anyway to do it.
Thanks and Regards,
P.Balaji
P.S : The above is not true for all the values. for example
if i give 22.1 i am getting 22.100000. And if i use double instead of
float, i can get the desired result but i want to use only float.