#include<stdio.h>
int main(void)
{
float a,b;
b=2.0e20+1.0;
a=b-2.0e20;
printf(“%f\n”,a);
return 0;
}
output is : 4008175468544.000000
how this can be possible????????????????
#include<stdio.h>
int main(void)
{
float a,b;
b=2.0e20+1.0;
a=b-2.0e20;
printf(“%f\n”,a);
return 0;
}
output is : 4008175468544.000000
how this can be possible????????????????
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
m also havin d same output 4 dis code…
n also the output is correct as the value 4 unsigned int can reach upto a number that can be expressed in the form of e…
float is of 4 bytes..so the value assigned by us to b is the case of overflow..hence the ans is of compiler’s choice..
actually its range is till 2million i.e 10 digits..
n also for accesing exponential we use %e instead of %f…
I agree with your point that if we will use some exponential term then %e must be used. but why we are getting the same value??.. it must for some specific reason.