![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
$
|
|
#3
|
|||
|
|||
|
Or do you mean a CEILING function which will raise a value to the nearest integer value? This would raise 104.4 to 105.
|
|||
| Google The UNIX and Linux Forums |