On Mon, 29 Oct 2007, andreas.rosenblad(a)ltv.se wrote:
2. floor(): Round down to nearest integer. A complement to the
commands ceil(), that round up to nearest integer. As int() gives just the
integer part, it gives the same value as floor() for positive values but
the values for ceil() for negative values, thus floor() is needed for
obtaining a round down to nearest integer for negative values. And floor()
is a standrad matematical function that shouldn't be absent from gretl.
Agreed. Just commited it to CVS.
I'm personally against introducing functions (with the associated
namespace pollution) for things that can easily be programmed
at the user level just like you said. IMO, anyone for which factorial(n)
is not obviously equivalent to gammafunc(n+1) shouldn't be writing
functions in the first place. Of course, I'm fully open to be convinced
of the contrary.
You may say that, by the same logic, one could define floor() as
f = (x>0) ? int(x) : -ceil(-x)
but, like you said, floor() is a standard function that should have been
there right from the start.
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche