Re: [dwm] Done Before: dwm stat scripts!

From: Enno \ <gottox_AT_gmail.com>
Date: Tue, 2 Oct 2007 17:56:17 +0200

> ...but it works...
It calculates as well as Excel :)
ceil n.0 gives n+1
e.g. ceil 0.0 gives 1

2007/10/2, Riccardo Murri <riccardo.murri_AT_gmail.com>:
> On 10/2/07, Kurt H Maier <karmaflux_AT_gmail.com> wrote:
> > If anyone knows how to cast
> > floats to int in bash let me know. :V
> >
>
> Not exactly efficient, but it works (pay attention to the spaces is
> round(), `expr` is especially picky...)::
>
> $ floor () { echo "$1" | sed -e 's|\.[0-9]\+||'; }
> $ floor 0.1
> 0
> $ floor 10.89
> 10
>
> $ ceil () { expr $(floor "$1") + 1; }
> $ ceil 0.1
> 1
> $ ceil 10.89
> 11
>
> $ round () { expr $(echo "$1" | sed -e
> 's|\.[0-4][0-9]*||;s|\.[5-9][0-9]*| + 1|;'); }
> $ round 10.89
> 11
> $ round 0.1
> 0
>
>
> Riccardo
>
>

-- 
http://www.gnuffy.org - Real Community Distro
http://www.gnuffy.org/index.php/GnuEm - Gnuffy on Ipaq (Codename Peggy)
Received on Tue Oct 02 2007 - 17:56:19 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:57:00 UTC