Looks like it was due to the number being too small.
In response to @NirMH, I am posting my comment as an answer.
%g
instead of %f
can print very small floating point numbers.
There are other options such as %e
, as @ilent2 mentioned in the comment.
For example:
double num = 1.0e-23;
printf("%e, %f, %g", num, num, num);
prints out the following result:
1.000000e-023, 0.000000, 1e-023