This is the mail archive of the 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: help understanding behaviour of unsuffixed float constants

Don't misunderstand - I like the behaviour. I don't want the unnecessary implicit conversions).

My concern stems only from the compliance to the standard. Some of our internal software standards require ISO99 compliance, as do standards imposed by our customers (e.g. Boeing via their D6).

If what I think is happening is actually happening, I can document a deviation. I just want to make sure that I am not missing something before going that route.


-----Original Message-----
From: Jakub Jelinek [] 
Sent: Thursday, May 22, 2014 3:27 PM
To: Regan, Brian (EPC COE)
Cc: ''
Subject: Re: help understanding behaviour of unsuffixed float constants

On Thu, May 22, 2014 at 07:16:43PM +0000, Regan, Brian (EPC COE) wrote:
> I wonder if someone could help shed light on this for me.

Why do you think this is a problem?  Conversion from float to double can't raise any exceptions, no bits are lost, and
(double) a < 200.0
a < 200.0f
have the exact same set of floating point values for which the condition is true resp. false.  So, the compiler chooses to optimize and narrow the comparison back to float comparison instead of double.

> static float a = 100.0;

> Also, the binary value of the constant 100.0 is compiled into 32 bits only.

Sure, because you initialize a float with 100.0, therefore it needs to be converted.

In any case, this should have been posted to gcc-help, it has nothing to do with development of gcc.


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