The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Round with awk AnnaLynn Shell Programming and Scripting 1 05-06-2008 11:55 AM
Round the column value : satyam_sat Shell Programming and Scripting 4 04-10-2008 08:30 AM
Srry Im a bit new round here..... BigDaddyDirt UNIX for Dummies Questions & Answers 3 03-17-2008 12:54 PM
round a number achieve Shell Programming and Scripting 2 09-14-2006 01:23 AM
round in KSH here2learn Shell Programming and Scripting 6 07-18-2006 09:18 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-08-2006
Registered User
 

Join Date: Aug 2005
Posts: 39
how to round a value

Hello,
In a unix shell script,i want to round a variabele to a nearest number

Ex: set count=104.4

How can i round that to 105.?

Thanks,
Sateesh
Reply With Quote
Forum Sponsor
  #2  
Old 02-08-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,614
You can't round 104.4 to 105 in base 10. But if you meant 104.6, you can do...
Code:
$ ksh
$ x=104.6
$ x=$(echo $x +.5 | bc)
$ x=${x%.*}
$ echo $x
105
$
Reply With Quote
  #3  
Old 02-08-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
Or do you mean a CEILING function which will raise a value to the nearest integer value? This would raise 104.4 to 105.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0