This is the mail archive of the gcc-bugs@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]

Re: printf("%0.0f", 0.5) yields unexpected result (0)


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

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