"James Kanze"
[...]
cases. But there are also a lot of threading issues which
don't lend themselves to testing, and some floating point
issues as well.
Please, you bring up a worry: you say some floating point
issues don't lend themselves well to testing. I use double
What tests would have issues with floating piont, if your
answer would be a) of interest to you or others or b) not
wildly offtopic?
Floating point is very, very tricky, because it's not linear.
Which means that at least in principle, and algorithm might work
for two values very, very near one another, and fail for a value
in between them. (And of course, the number of possible
floating point values generally precludes exhaustive testing.)
The result is that you do very, very careful numerical anaysis
to prove that your algorith will behave linearly over a given
range, despite the descrete nature of machine floating point,
then test the ends of the range exhaustively, and add a few
random tests elsewhere. In some cases, in fact, you'll find
that you'll have to use two different algorithms, depending on
the input, since no one algorithm will be linear over the entire
range---in such cases, of course, you'll test very insensively
around the switch-over point.
Thank you very much.
I'm aware the machine itself can (and does) generate "rounding errors" that
vary, much as you describe (close-to-same floats, perhaps error beyond the
fifteenth(?) decimal place).
My implementation is likely not suffering: I haven't seen a single exception
thrown by the operating system even in literally days of continuous running
flat-out.
I also have a suspicion that the error(s) may _help_ me: the program deals
with points tight against one another (this is oddball geometry) in a 3D
space. Without details, it's possible for two to get 'stuck' inside a
'cage' of twelve, hence be right on top of each other, to extreme precision
beyond the double's . I suspect that the seemingly random machine
rounding error can cause them to be _not_ right on top of each other, enough
to un-stick them.
(Pardon wordiness; I know the purpose of the program isn't of interest, only
its coding is (maybe).)
(My "tests" so far have consisted of simple right-answer
checks and of sending the .exe I write with Windows 98 to
friends with different operating systems --albeit all
Micro$soft'$-- and seeing if it chokes and dies or not. (So
far, not.))
Right-answer checks for what input? The problem is that an
algorithm which gives a correct answer for some input might give
a wrong answer for other input. (Although I've never actually
seen the case, I've heard stories---and it sounds plausible---of
functions that returned the correct answer for all but two or
three values in the entire floating point range. In one case,
at least, there were just a couple of values where the function
failed to converge, due to imprecisions in the floating point
arithmetic, and the program went into an endless loop.)
Right answer checks to see if I'm doing something stupid.
(*g*) Inputs to my specialized calculation functions are things I can't
directly check very easily, and what the program does makes it essentially
irrelevant even if there were a (tiny? not large?) floating point error
(except for the helper error maybe, abovementioned): numbers exist for so
fleeting a time before being changed (xyz coords, mostly), that any error
can't propagate or concatenate. It gets swamped, fuzzed out.
If the graphical output (I use an accessory program to see) is what it's
supposed to be --and it always is-- then the errors if they exist for micro-
or nano-seconds, are not a problem for me.
I was worried when you said that about floating point issues, that you knew
something C++-specific that might have amplified these errors, but I see
that's probably not the case.
Inputs
<...>
If you're using floating point, be very cautious about numeric
stability. Machine floating point are NOT real numbers, and
many of the rules of real number arithmetic don't always hold:
e.g. (a + b) + c != a + (b + c) in many cases.
I was more or less aware, but needed to know what you meant.
I thank you _very_ much.