I'm doing a very basic printout of scientific notation.
But, it appears to me its not working and I can't figure out why?
Code:
size_t result = 0;
printf("%e \n",result);
Value it prints is below:
1.278341e-307
What would be right way to do scientific notations?
If you use a floating-point printf format code, like %e
, the matching argument must be a double
. But you are passing it an integer (size_t
).
Printf does not know the types of its arguments, so you have to tell it what they are by using the correct format code. If you lie to it, you will get undefined results.
And if you are using gcc or clang, please always use the -Wall
command-line option and read the warnings. That will save all of us a lot of trouble.