Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: why do ceil/floor give the decimal dot?
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:
> It's not an oversight. The doc says:
>
> Most functions take floating point arguments and
> return a floating point value. However, any
> necessary conversions from or to integer type will
> be performed automatically by the shell. Apart from
> atan with a second argument and the abs, int and
> float functions, all functions behave as noted in
> the manual page for the corresponding C function
> [...]
>
> So ciel and floor return float precisely and
> intentionally because the C functions do so.
Take a look at this [1] zsh:
prefix-len () {
local hosts=$1
echo $(( 32 - int(ceil(log($hosts)/log(2))) ))
}
without the integer conversion, the output for
prefix-len 30
isn't 27, but "27."
[1] http://user.it.uu.se/~embe8573/conf/.zsh/web
--
underground experts united
http://user.it.uu.se/~embe8573
Messages sorted by:
Reverse Date,
Date,
Thread,
Author