← Top stories The KL Divergence Is Never Negative, Except in PyTorch ↗ (opens external site) 97 points by Anon84 5 days ago | arxiv.org | 40 comments on HN ↗ View full thread · View on Hacker News Comment thread (1) n923263 | 4 days ago | parent | reply +0 would also be annoying - there's not really a good answer here.A result of -0.0 can mean two things (not counting it just being wrong):a: the real (as in number) result is exactly zero, with a negative sign by coincidence (eg (1-1)/(0-1)).b: the real result is strictly less than zero, but even tinier than the smallest denormal, so it was rounded up to zero.Case (a) means you must have sqrt(-0) == 0, or you get problems like derf_'s.In case of case (b), having a square root be negative (impossible!) is the best indication we can squeeze in that something might be weird.
A result of -0.0 can mean two things (not counting it just being wrong):
a: the real (as in number) result is exactly zero, with a negative sign by coincidence (eg (1-1)/(0-1)).
b: the real result is strictly less than zero, but even tinier than the smallest denormal, so it was rounded up to zero.
Case (a) means you must have sqrt(-0) == 0, or you get problems like derf_'s.
In case of case (b), having a square root be negative (impossible!) is the best indication we can squeeze in that something might be weird.