This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: IEEE 754 Compliance


On Wed, Sep 18, 2002 at 02:22:30PM +0530, D.Venkatasubramanian, Noida wrote:
> Hi all,
> 
> 	According to IEEE 754 Specifications :

[snip brief description of IEEE floats and doubles]

> 
> Shouldn't GCC atleast follow these specifications for all targets.

No.  Not all targets support IEEE floats directly.  For those targets
that have hardware-support for non-IEEE floats only it would be natural
for gcc to use that format instead as long as it follows the C standard
(which has much more lenient requirements for floating point types.)


> 
> Test Case no. gcc.c-torture/execute/ieee/20010226-1.c execution
> 
> I ran make-check for h8300-elf target cross-compiler built on an x86 host
> platform.
> I found the test case failing.
> 
> On investigation, I found out that the sizeof double or long double on h8300
> is 4 bytes. Obviously, the test case fails. On an x86 target, the size was 8
> and 12 bytes respectively.
> 
> The size of long double on h8300 targets is 4 bytes in contrast to 12 for
> x86 targets.

That sounds bad.  The C standard requires a double to have at least 10
decimal digits of precision. (A float only needs 6 digits of
precision.) I don't think the requirements for a double can be
fulfilled with only 32 bits. You need more than 40 bits for that. (The
requirements for a long double are the same as for double and is indeed
identical to double on most machines.)


> 
> h8300-elf-gcc -mh
> Running on a simulator
> Size of data types
> Int          : 2
> Long Int     : 4
> Float        : 4
> Double       : 4
> Long Double  : 4
> 
> I do think, that h8 being a 16 bit microprocessor or microcontroller, would
> slow down any program considerably if it uses double with 64 bits, requiring
> many memory accesses. But somehow, shouldn't GCC move towards, fixed sizes
> for data types (except the pointer sizes, of course), such as Java does. And
> maybe, release an advisory that GCC may slow down for certain data types on
> certain machines. There is always a float to do the same job of a double in
> H8. I don't say, the present GCC violates any C Standards, its just that,
> wouldn't fixed sizes go a long way in making programs more portable. 

Identical representation of types on all machines would be a Bad Idea
since that would slow down some targets unncessarily and quite likely
cause incompatibility with the system compiler on that target.

> 
> Any thoughts on the same.
> 
> Thanx and regards,
> 
> Venky


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]