The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
Rounding off to the next whole number
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
Rounding off to the next whole number
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
3
(
permalink
)
07-17-2008
fpmurphy
Moderator
Join Date: Dec 2003
Location: Florida
Posts: 1,930
Humm, if you really want to round 10.8/5 to an integer the answer should be 2 not 3. What you are looking for is to round up i.e. ceil(10.8/5)
Code:
$ num=2.16 $ print $((floor(num))) 2 $ print $((ceil(num))) 3 $
fpmurphy
View Public Profile
Visit fpmurphy's homepage!
Find all posts by fpmurphy
Find fpmurphy's past nominations received
Find fpmurphy's present nominations given