You are here: Re: why does 69.99*100=6998? « PHP Programming Language « IT news, forums, messages
Re: why does 69.99*100=6998?

Posted by Rik Wasmus on 02/01/08 16:15

On Fri, 01 Feb 2008 16:59:18 +0100, The Natural Philosopher <a@b.c> wrot=
e:
> The question says it all.
>
> I have an input box, which I fill in with a price.
> IOt gets passed to the main form as a variable, then shoved into an SQ=
L =

> field vue a print '%d' statement where the argument is $price*100.

Could you give us the exact code & input values? And what database =

(&version) are you using?

> For some reaosn, this particular value goes to 6998.
>
> If I update hee database manually to 6999, it displays as 69.99.
>
> If I enter 69.999 it updates as 6999..not 69999

Seems to have something to do with float/double precision. However, the =
=

precision isn't that big, and I cannot reproduce it in PHP 5.2 here..

PHP5.2.4:
<?php echo 69.99*100 ?> =3D> output 6999
MySQL5.0.45-community-nt:
SELECT CAST(69.99*100 AS UNSIGNED); =3D> 6999
-- =

Rik Wasmus

 

Navigation:

[Reply to this 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

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