Q:15 Statement given: b=2.0e20+1.0;
a=b-2.0e20;
what is ’2.0e20′,?anybody executed it explain the result of ‘a’..
Q:15 Statement given: b=2.0e20+1.0;
a=b-2.0e20;
what is ’2.0e20′,?anybody executed it explain the result of ‘a’..
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
it will be showing some random value….because float data type have precision till e7….after this it starts giving some random value…and in this above equation you are trying to modify 21st digit which is not possible.
e20 is the scientific notation……it means 10 to the power 20
Hi here is my code take a look ..
I am also skeptic about the answer…
e-notation basically 2.0e20(or AeN) represents 2.0 * 10^20..
#include
#include
int main(void)
{
float a,b;
b = (2.0*pow(10,20)) + 1.0;//2.0e20 Can be expressed as 2.0 * 10^20
printf(“Value of b is %f\n”,b);
float c = 2.0e20;
printf(“Value of c is %f\n”,c);
a = b – (2.0*pow(10,20))/*c*/;//if I replace the exp with var c result changes to 0.0000….
printf(“Value of %f – %f = %f \n”,b,c,a);//Result seems lil Strange
return 0;
}
=============output=================
for the code in question
[root@linuxstation asgmt]# ./fourteen
./fourteen
Value of b is 200000004008175468544.000000
Value of c is 200000004008175468544.000000
Value of 200000004008175468544.000000 – 200000004008175468544.000000 = 4008175468544.000000
+++++++++++++output+++++++++++++++++++
when I replace the a = b – c ;
[root@linuxstation asgmt]# make fourteen
make fourteen
cc fourteen.c -o fourteen
[root@linuxstation asgmt]# ./fourteen
./fourteen
Value of b is 200000004008175468544.000000
Value of c is 200000004008175468544.000000
Value of 200000004008175468544.000000 – 200000004008175468544.000000 = 0.000000
[root@linuxstation asgmt]#