I’ve got a double that prints as 0.000000 and I’m trying to compare it to 0.0f, unsuccessfully. Why is there a difference here? What’s the most reliable way to determine if your double is zero?
I’ve got a double that prints as 0.000000 and I’m trying to compare it
Share
To determine whether it’s close enough to zero that it will print as
0.000000to six decimal places, something like:Dealing with small inaccuracies in floating-point calculations can get quite complicated in general, though.
If you want a better idea what value you’ve got, try printing with
%ginstead of%f.