tags:

views:

30

answers:

1

iam doing division of these two columns $row['col1']/$row['col2'] iam getting value as 0.0042553191489362

How do i round up the value so that i can get as 0.42%

+2  A: 

You can use the round built in function:

$myFloat = $row['col1']/$row['col2'];
$result = round($myFloat, 2);
John McCollum
@John: Please See my question updated on top
Someone
OK...multiply it by 100 then apply round?
John McCollum
@JOhn: How do i do in Single statement .is there any thing wrong with this statement such as operator precedence round($row['col1']/$row['col2']*100,'2')
Someone
Well, the second parameter shouldn't have quotes round it, and to me, the first parameter is ambiguous: does the author mean ($row['col1']/$row['col2'])*100 or $row['col1']/($row['col2']*100) ?
John McCollum