Handling promotion (and demotion) between single and multi-precision
integers is fairly easy. And once you have that doing it for rationals
is basically free. Likewise promoting an Integer up to rational is
trivial and vice versa. But promotion (or demotion) between IEEE floats
and rationals is really hard and I don't know of a language that even
tries. The major problem is that the demotion from rational to IEEE
float is very lossy. In general, there are many possible distinct
rationals that convert into the same IEEE value and converting IEEE
float to the simplest rational out of that set is a very expensive
operation.. Once you're in rationals you probably never want to demote
back to IEEE (except possibly at the very end). Every language that
supports rationals, that I know of, leaves it up to the programmer to
decide whether they will be doing computations in IEEE float or
rationals and do not try to automatically convert back and forth. I
looked at thos and basically gave up when I was writing the perl 5
Bigint and Bigrat packages.
Before you discuss implementations, you should define exactly what rules
you are going to use for promotion and demotion between the various types.
--
Mark Biggar
Perl'sMaternal Uncle
[EMAIL PROTECTED]
[EMAIL PROTECTED]