You are here: problems with float conversion from a string « PHP Programming Language « IT news, forums, messages
problems with float conversion from a string

Posted by Remo on 12/06/07 15:02

Hi everyone,
I'm a php newbie. I'm sorry for the trivial question:

If I have two string variables like:

$Media_A = "8.00"
$Media_B = "8.86"
and I try to use this statement in order to make a subtraction
like:
$Media_B - $Media_A, result is 0!
Why????

It's like two strings has been converted into integers.
I say that, why, if I set $Media_B="9.86", new result is 1.

This example uses strings because values coming from a table where
field are defined varchar(7).
Is there a way to cast those variables and calculate the correct
differences between those two variables values.

thanx for help
Remo

 

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

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