winmastergames Posted June 13, 2008 Share Posted June 13, 2008 Well i made this little script to turn Watts into KW by dividing the number by 1000 This Code: <?php echo floor($_GET['number']/1000); ?> But, It doesn't have any decimal places as an example if you used this code with 3500 it will give out 3 is there any way to make it have one decimal place so it will give out as an example 3.5 Thanks Alot Link to comment https://forums.phpfreaks.com/topic/110025-solved-math-in-php/ Share on other sites More sharing options...
bluejay002 Posted June 13, 2008 Share Posted June 13, 2008 floor() will not help at all. it rounds up to integer only, though it returns float since its bigger. use round() instead: round(($_GET['number']/1000), 2); cheers, Jay Link to comment https://forums.phpfreaks.com/topic/110025-solved-math-in-php/#findComment-564578 Share on other sites More sharing options...
zenag Posted June 13, 2008 Share Posted June 13, 2008 <? echo number_format($_GET['number']/1000,2); ?> Link to comment https://forums.phpfreaks.com/topic/110025-solved-math-in-php/#findComment-564580 Share on other sites More sharing options...
winmastergames Posted June 13, 2008 Author Share Posted June 13, 2008 thanks ill try them EDIT: First One worked Link to comment https://forums.phpfreaks.com/topic/110025-solved-math-in-php/#findComment-564583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.