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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rounding numbers

Status
Not open for further replies.

tonyjob

Programmer
Nov 20, 2000
25
GB
how can you round a number up? so if the numbers 8.09181 it will round up to 9?
 
one guess.....

Code:
#!/usr/local/bin/perl

$num = '8.0134';
if ($num - int($num)) { $num = int(++$num); }
print "$num\n";

'hope this helps.





keep the rudder amid ship and beware the odd typo
 
thanks for your help, i used a different technique. i added 0.9999999 to the number and then cut the decimals off.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top