Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: why do ceil/floor give the decimal dot?
On May 14, 2:32am, Emanuel Berg wrote:
} Subject: why do ceil/floor give the decimal dot?
}
} >From #zsh (incal == yours truly):
}
} <incal> why do ceil/floor give the decimal dot?
} echo $(( floor(5) )) -> 5. Isn't that the
} whole "point" that you want an integer? I know
} I can get it with int but I thought I'd learn
} if there is a reason
}
} <danielsh> incal, I suspect that's an oversight.
} <danielsh> incal, it just uses the C floor() function,
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author