You are here: how to stop variable rounding up after a division « PHP Programming Language « IT news, forums, messages
how to stop variable rounding up after a division

Posted by mantrid on 10/07/06 18:36

I am trying to take an integer and divide it by 100 to give a decimal to
store in my database. The field in my mysql database is set to decimal(4,2)
My php is
$price=number_format($price/100,2);
Ive also tried
$price=number_format($price,2)/100;

but neither work it keeps rounding any value less than 100 to 1 whereas I
want it to store the value to two DP

eg

80 becomese 1 instead of 0.8
180 becomes 2 instead of 1.8

does anyone know how to do this?
Ian

 

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

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