Page 1 of 1

math calculation issue

Posted: Fri Jun 24, 2005 7:07 am
by itsmani1

Code: Select all

$percent1 = $percent / 100;
$percent1 = $price * $percent1;
when $percent1 = 24.02
and $price = 12
the above expressgives me result zero in $percent1

Posted: Fri Jun 24, 2005 8:50 am
by Chris Corbyn
Where did you define $price and $percent.... the expression alone is zero if they haven't been defined correctly :?

Code: Select all

$price = 12;
$percent = 24.02;

$percent1 = $percent / 100;
$percent1 = $price * $percent1;
echo $percent1;
2.8824

Re: math calculation issue

Posted: Fri Jun 24, 2005 8:52 am
by Chris Corbyn
itsmani1 wrote: when $percent1 = 24.02
Is that a typo? $percent1 is what you are calculating and if that is defined instead of $percent that explains the problem ;)