[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Re: mixed decimal floating and binary floating arithmetic
From: "Fred J. Tydeman" <tydeman@xxxxxxxxx>
To: "fred.zemke@xxxxxxxxxx" <fred.zemke@xxxxxxxxxx>,
"stds-754@xxxxxxxx" <stds-754@xxxxxxxx>
Date: Wed, 15 Apr 2009 11:01:20 -0700 (PDT)
On Wed, 15 Apr 2009 10:32:32 -0700, Fred Zemke wrote:
I don't see any guidance in Clause 10.1 "Expression evaluation rules"
about this situation, unless it is the last sentence "Language standards
should disallow, or provide warnings for, mixed format operations that
would cause implicit conversion that might change operand values".
The C language disallows (implicit) mixed format (binary FP and decimal FP)
operations in most cases.
The C committee has issued a technical report on adding support for
decimal floating point to the C language. The relevant section from
that TR is:
ISO/IEC DTR 24732 WG14 N1312
6.4 Usual arithmetic conversions
In an application that is written using decimal arithmetic, mixed
operations between decimal and other real types are likely to occur
only when interfacing with other languages, calling existing libraries
written for binary floating point arithmetic, or accessing existing
data. Determining the common type for mixed operations is difficult
because ranges overlap; therefore, mixed mode operations are not
allowed and the programmer must use explicit casts. Implicit conversions
are allowed only for simple assignment, return statement, and in
argument passing involving prototyped functions.
---
Fred J. Tydeman Tydeman Consulting
Fred (Zemke),
The statement in 10.1 IS the guidance. That is, mixed radix
operations should be disallowed. It is a 'should' rather
than a 'shall' because we didn't think we could prevent it
in all cases.
But if you search through the standard for the words 'mixed'
or 'radix' you will find a number of statements that implicitly
assume mixed radix operations are not an option.
As Fred (Tydeman) shows, the C language committee has already
followed this guidance for all the obvious reasons.
It was our intent that Fortran disallow it as well.
Realize that it is IMPLICIT conversions that are being
disallowed. You may still support mixed radix operations so
long as the programmer specifies the radix of the operation
by EXPLICITLY converting one operand to the other's radix.
But it is a 'should' & you are free to decide this as you will.
You know, I think this is the first time in my life I've had
to further qualify my Freds in a statement. :-)
Interesting...
Dan