Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding a number off 1

Status
Not open for further replies.

nfaber

Technical User
Oct 22, 2001
446
0
0
US
Greetings,

I have a int variable I wish to round off. an example is:

$num = 171.674560185185

This represents:

171 days

.674560185185 % of one day


I wish to round off .674560185185 in this case to .675

Any ideas?
 
Straight from perlfaq4:
Code:
printf("%.3f", 3.1415926535);	# prints 3.142
# alternatively
$rounded_num = sprintf("%.3f", 3.1415926535);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top