From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nanakos Chrysostomos Subject: Re: float Date: Fri, 08 Jan 2010 19:21:31 +0200 Message-ID: <4B47699B.7000906@wired-net.gr> References: <4B476184.9070407@wired-net.gr> <87hbqwwmgb.fsf@erwin.mina86.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <87hbqwwmgb.fsf@erwin.mina86.com> Sender: linux-c-programming-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Michal Nazarewicz Cc: phoenixxz , linux-c-programming@vger.kernel.org On 8/1/2010 19:11, Michal Nazarewicz wrote: >> On 8/1/2010 18:30, phoenixxz wrote: >> >>> float i=1.34; >>> printf("%f",i); >>> >>> ->> 0 >>> why? >>> > Nanakos Chrysostomos writes: > >> printf("%lf",i); >> > %lf is actually invalid format (though glibc will gladly treat it the > same way it treats %f). When passing a float value to a function with > variable number of arguments it is promoted to double. > > Sorry for the previous one... it could be then. printf("%f",(double)i);