[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mixed decimal floating and binary floating arithmetic



Vincent Lefevre wrote:

So, if you have an operation between a binary64 and a decimal64, which
format would you choose for the result? And why?

Ditto with binaryM and decimalN for any M and N.
The standard has a set of rules for deciding this; basically if one kind has more "decimal precision", that's the one that gets picked. If they both have the same decimal precision, the compiler gets to choose, but it has to choose one of the operand kinds.

For that matter, operations involving single-precision complex and
double precision real are similarly "bad". In fact enormously worse
than mixing similar precisions of binary and decimal!

I don't know FORTRAN, but a language should be designed to perform
the operation in double-precision complex.
I agree, and as soon as I have my time machine working I'll pop back 30-odd years and make it so.

Steven Hobbs wrote:
The statement that Fortran always has allowed mixed mode is not true.
Yes it is - it has always allowed mixing all kinds of floating-point (at least in the standard). You are right that mixing integer and real in an expression "only" goes back 31 years (in the standard). Of course prior to Fortran 90 the standard only supported two kinds of floating-point (single and double precision) though compiler support for more kinds than that was not that uncommon.

However, the Fortran committee will do whatever it wants
and probably will pay no attention to Fortran history
We pay a great deal of attention to "history" in the form of backwards compatibility (more than most).

The precision problems and performance problems might cause the Fortran
committee to punt the question of defining what happens if they allow
mixed mode.
As I said, we already allowed it. It is crystal clear in Fortran 90, 95 and 2003 that all kinds of REAL (i.e. floating-point) can be mixed in a single expression, and there are rules to say what the answer is.

As I said,
It seems unlikely that we will choose
to be deliberately incompatible with previous standards; not impossible,
but unlikely.
The reasons for choosing incompatibility here still seem less cogent to me than removing mixed-kind real/complex arithmetic; I have not heard much support for that idea, that's why I think it's unlikely. Whichever way the standard jumps on the matter, I feel sure that some/most/all compilers will warn the user about poor performance if they use decimal floating-point anyway, and especially if they mix their modes.

Cheers,
--
.....................Malcolm Cohen, Project Editor, Fortran Standard.


754 | revision | FAQ | references | list archive