This is the mail archive of the
mailing list for the GCC project.
RE: help understanding behaviour of unsuffixed float constants
- From: "Regan, Brian (EPC COE)" <brian dot regan at honeywell dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Date: Thu, 22 May 2014 19:36:24 +0000
- Subject: RE: help understanding behaviour of unsuffixed float constants
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=neutral (sender IP is 126.96.36.199) smtp dot mailfrom=brian dot regan at honeywell dot com;
- References: <61F2AE955326E042B27D898DD66AE04B33F0C890 at DE08EX3006 dot global dot ds dot honeywell dot com> <20140522192722 dot GL10386 at tucnak dot redhat dot com>
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.
From: Jakub Jelinek [mailto:email@example.com]
Sent: Thursday, May 22, 2014 3:27 PM
To: Regan, Brian (EPC COE)
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.