C ckevin New Member Jun 10, 2002 #1 How can I round off integers so that it can have exactly 1 dec. place? E.g. if I use PHP "round" command: when the value is 4, the outcome is 4 the value is 4.123, the outcome is 4.1, what I really want is value 4 --> outcome 4.0 value 4.123 --> outcome 4.1 Thanks!
How can I round off integers so that it can have exactly 1 dec. place? E.g. if I use PHP "round" command: when the value is 4, the outcome is 4 the value is 4.123, the outcome is 4.1, what I really want is value 4 --> outcome 4.0 value 4.123 --> outcome 4.1 Thanks!
bigperm Doot Do Do Do NLC Jun 10, 2002 #2 from php.net float round ( float val [, int precision]) Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). Click to expand... So it looks like round (4, 1) will return 4.0
from php.net float round ( float val [, int precision]) Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). Click to expand... So it looks like round (4, 1) will return 4.0
C ckevin New Member Jun 11, 2002 #3 bigperm, I have tried, but the outcome is "4" only... PHP: <? $row = round(4,1) ; echo "$row" ; ?> You can try yourself, and my php version is 4.0.6 Thanks! Kevin
bigperm, I have tried, but the outcome is "4" only... PHP: <? $row = round(4,1) ; echo "$row" ; ?> You can try yourself, and my php version is 4.0.6 Thanks! Kevin
Dusty NLC NLC Jun 11, 2002 #5 Round won't do what you're trying to accomplish, use printf instead (or sprintf if you're doing something with the variable other than printing it). printf("%.1f",$row);
Round won't do what you're trying to accomplish, use printf instead (or sprintf if you're doing something with the variable other than printing it). printf("%.1f",$row);