Answer the question
In order to leave comments, you need to log in
Why does dividing 0 by -5 result in -0?
Or, in general, when dividing 0 by any real negative number, you get -0. How to get rid of this, and make it so that it outputs not -0, but 0 to the console. I can roughly guess why: when dividing an infinitely small by a simply negative number, it turns out infinite a small negative value, it cannot be written to double, so it turns out -0. So how do you get rid of this -0 ?
Answer the question
In order to leave comments, you need to log in
You can do something like this:
#include <cfloat>
...
if (res > -DBL_EPSILON && res < DBL_EPSILON) res = 0;
cout << res;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question