Reply to Re: problem with fmod()

Your name:

Reply:


Posted by Tim Roberts on 11/30/07 06:00

bummerland@gmail.com wrote:
>
>I have a problem with the function fmod.
>
>Why is fmod(5.7, 0.1) = 0.1 ?? Why is it not 0?

Because floating point arithmetic is not exact. The number "5.7" cannot be
represented exactly in binary. So, it's quite likely that you are really
computing something like fmod(5.69999999999999, 0.1), and that result would
be 0.09999999999999, which will print as 0.1.

It's not the function that is broken, I am afraid. It is your
expectations.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация