Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: why do ceil/floor give the decimal dot?



On May 14, 2015, at 5:38 PM, Emanuel Berg <embe8573@xxxxxxxxxxxxx> wrote:

> I like the solution better to have the types all
> floats (or whatever) and then use printf to make it
> look the way you want.

You should use %g then (with appropriate precision) because %d does an
implicit conversion.

    % printf '%d\n' $(( 1e20 ))
    -9223372036854775808

    % printf '%g\n' $(( 1e20 ))
    1e+20

    % printf '%.30g\n' $(( 1e20 ))
    100000000000000000000

vq



Messages sorted by: Reverse Date, Date, Thread, Author