On 10/2/07, Kurt H Maier <[EMAIL PROTECTED]> 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