Forum Moderators: coopster

Message Too Old, No Replies

PHP Multiplication of floating point numbers

         

username

8:12 am on Aug 3, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi, I have a strange issue where php returns 0 as the result for:

$width = 440;
$height = 530;
$newwidth=200;
$ratio = $newwidth/$width;
$newheight = ($ratio * height);

This prints 0 for $newheight, when it should return 238.5, or at least 239 following round.

Can anyone answer this for me please? Thanks.

Habtom

8:22 am on Aug 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nothing wrong really, except

height is a variable, you need to change height to $height