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: 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
and
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.

	Jakub


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