Floats are not a subset of complex. I concur
with Roy Smith's comments on that issue. There's
Yes they are.
no reason why complex numbers cannot be
represented by a pair of integers, or rationals,
or the new floating decimal type, or whatever.
I think this is getting sidetracked. This started
with a request for a better test to check whether
something is near enough something else. Since
all your alternatives give exact results you don't
need to test for nearness you test for equality.
So within this contexts where you can't calculate
things exactly floats are a subset of complex.
In addition, you're going to have to do significant
type checking if you want to combine floats and
complex in the same method call. That's just
poor design.
No you don't. Please explain why something like
abs(a - b) < tolerance
needs typechecking when a and b can be complex
numbers as well as floats
I take it you've never worked with FIT. It's intended
to be used by non-technical people on a project, such
as the on-site customer, business analysts and so forth.
If I did something as silly as requiring them to insert
a tolerance that is blatently obvious to anyone looking
at the number involved, I'd get a change request so fast
that the edges would char from the friction.
A tolerance is never blatantly obvious from looking
at the number involved. On a number like 6.23e14
the tolreance could be 5e11 or 3e12 in fact from
just looking at the number I would guess at a tolerace
of 1e12, in other words bounds between 6.22e14 and
6.24e14.
Besides you are mixing user interface and implementation.
There is nothing stopping you from inferring this obvious
tolerance and using it in your program. The fact that
the user just insered 6.23e14, doesn't stop you the
programmer to test whether a second number lies within
a fault tolerance of 5e11 of 6.23e14