otuatail Posted May 22, 2010 Share Posted May 22, 2010 Hi I can't work this out if($row['FileSize'] < 10000){?> <td><?=$row['FileSize']?></td> <?} else if($row['FileSize'] > 10000){ $val = (int) $row['FileSize'] / 1000 ?> <td><?=$val?> K</td> <?}?> This displays 62.718 K not 62 K /* ignoring the discrepancy of 62.*/ Link to comment https://forums.phpfreaks.com/topic/202590-how-to-use-int/ Share on other sites More sharing options...
Mchl Posted May 22, 2010 Share Posted May 22, 2010 $val = (int) ($row['FileSize'] / 1024); Link to comment https://forums.phpfreaks.com/topic/202590-how-to-use-int/#findComment-1061986 Share on other sites More sharing options...
Daniel0 Posted May 22, 2010 Share Posted May 22, 2010 Have a look at the operator precedence table. Type casting takes higher precedence than division. Link to comment https://forums.phpfreaks.com/topic/202590-how-to-use-int/#findComment-1061988 Share on other sites More sharing options...
ignace Posted May 22, 2010 Share Posted May 22, 2010 You also have intval, floatval, doubleval, and strval. Link to comment https://forums.phpfreaks.com/topic/202590-how-to-use-int/#findComment-1061990 Share on other sites More sharing options...
otuatail Posted May 22, 2010 Author Share Posted May 22, 2010 Thanks guys and especialy Mchl yes it is 1024 not 1000 Desmond. Link to comment https://forums.phpfreaks.com/topic/202590-how-to-use-int/#findComment-1061993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.