Page 1 of 1

percentages of over 1000

Posted: Wed Dec 01, 2004 1:52 am
by bradles
For some strange reason if I try and get 10 % of my session variable $x when it is over 1000 I end up with the answer being 0.1 when it should be 100.

I have tried with amounts under 1000 like 975 and it returns 97.5 as it should but the minute i go over 1000 i get 0.1.

Stupid thing is that I can do it in a test script and everything seems fine.

Code: Select all

$x = 1650.00;
$y = 0.1;
$result = $x * $y;
echo "x*y = $result";

Does anyone know what this could be? I have spent about 3 hours trying to figure this out and still no luck.

Brad

Posted: Wed Dec 01, 2004 3:07 am
by kettle_drum
Dont <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> yourself off wondering why it doesnt work and use a different method:

Code: Select all

$result = ($x/100)*10;
$result = $x/10;

Posted: Wed Dec 01, 2004 3:26 am
by djot
-
Hi,

your script echos "165" as it should. Can't redo your error.

djot
-