Jeff said:
"Real" math? Whatever you say. In EE college courses, professors often
use -0 to represent the limit of an asymptotic function that approaches
zero from the negative side, e.g. the voltage decay of a negatively
charged capacitor. The use has nothing to do with computers or IEEE
floats.
Anyway, take it up with the OP; AFAIK, his question was academic, but
maybe he has an interesting use case.
In fact, the -0.0 in programming is not very similar to the real math
lim_{x->0-}(x). The simplest proof of this is the fact that -(1.0-1.0)
gives -0.0, while after pushing the minus into the parenthesis we get
-1.0+1.0 which gives 0.0. So I wouldn't say that -0.0 resembles the
limes of capacitor charge, maybe only a bit. But if we wanted some more
real math logic, we would need also +0.0 (different from 0.0), begin the
result of 1.0/infinity. Then we would have -(+0.0) = -0.0, but -(0.0) =
0.0. But still it's only some approximation of "real math".
Because of these inconsistency in IEEE (inconsistency with the real math
or physics, I mean, not in IEEE itself), I'm not trying to use -0.0 as a
real limes of something. The real use case is as follows (if anybody
should be interested):
A car can drive forward or reverse, but after it brakes to stop after,
say, going forward, it needs to spend a short time staying still before
it can start going backwards. This is a way of modelling the time needed
to switch the gear from 1 and R (and the same applies to switching from
R to 1). So now if I'm controlling the car, then I should be able to
give it the desired velocity (the set point to a controller). So I
decided that 0.0 means "don't move and be ready to go forward
immediately (while I know there will be a moment's pause if I want to go
backwards now)", while -0.0 means "don't move but stay switched to
reverse, so that there's no time needed to start driving reverse (while
a moment will be needed should I decide to go forward)". That's it, just
one more bit of information pushed into the value of zero, which is
exactly where I need it.
TPR.