Register
It is currently Fri Oct 24, 2014 2:25 am

rounding numbers/integers in AWK


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Mon May 16, 2005 8:31 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
Originally posted by Mekanik

Quote:
how to round numbers in AWK


Code:
# printf "450.49999999999997\n" | awk '{print int($0+0.5)}'
450
#

# printf "450.49999999999999\n" | awk '{print int($0+0.5)}'
451
#

# printf "9.5\n" | awk '{print int($0+0.5)}'
10
#

# printf "9.4\n" | awk '{print int($0+0.5)}'
9
#


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP