Michael Cramer on 17 Sep 2009 09:42:04 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] floor/ceil in bash?


For a shorter, more obscure version, you could use the reverse-polish, dc calculator instead:

#!/bin/bash

A=$1
B=$2

function ceil { echo "[1+]sa $1 $2 ~ 0 !=a p" | dc; }

C=$(ceil $A $B)

echo "C=$C"


--
Mike Cramer
http://www.webkist.com/
215.769.2505 // AIM/Skype/Etc: MikeWebkist
___________________________________________________________________________
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