This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: printf("%0.0f", 0.5) yields unexpected result (0)
- To: Marc Boeren <M dot Boeren at guidance dot nl>
- Subject: Re: printf("%0.0f", 0.5) yields unexpected result (0)
- From: Horst von Brand <vonbrand at inf dot utfsm dot cl>
- Date: Thu, 17 Aug 2000 09:43:23 -0400
- cc: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
Marc Boeren <M.Boeren@guidance.nl> said:
> I noticed the following behaviour using printf:
>
> printf("%0.0f", 0.5); // prints 0
> printf("%0.0f", 1.5); // prints 2
> printf("%0.0f", 2.5); // prints 2
> printf("%0.0f", 3.5); // prints 4
Round to next even digit if .5, what's strange about that?
--
Dr. Horst H. von Brand mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513