Jason Stelzer on 16 Sep 2009 13:09:51 -0700 |
The details are boring and irritating, but I'm looking to get the ceil for something in bash. Here's how I'm brute forcing it. # This holds the value for the getCeil function _MY_CEIL="" # By default, bash is giving me back the floor for arithmatic. I want the ceil. # this implements this. getCeil(){ MAX=$1 DIVISOR=$2 X=$((${MAX}/${DIVISOR})) while [ $(($X * $DIVISOR)) -lt ${MAX} ] ; do X=$(($X + 1)); done _MY_CEIL=${X}; } Is there an easier way? And yeah, I know that using _MY_CEIL as a bucket is kind of weird. Either way the code looks odd to me. getCeil X Y MY_VAR=${_MY_CEIL} vs MY_VAR="" getCeil X Y ${MY_VAR} -- J. ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|