Why is everyone "numeric" ?
class(ceiling(3)) class(ceiling(3L)) class(ceiling(3.1)) class(floor(2)) class(floor(2L)) class(floor(2.1))
This is similar to one arithmetic operation, where the result is uniquely an integer (as opposed to, say, exponential ), regardless of the input (this is an error for transmitting a complex number).
I tried to talk for the answer related to the base C code, but nothing really worked out.
I also found out that although "%/%"(x,y) should always be an integer as well, the class results depends on the input types, for example. 5%/%2 , 6%/%2 and 6%/%2L are all numeric , but 5L%/%2L and 6L%/%2L both integer (something is mentioned in ?Arithmetic ); it doesn't make sense to me either, but at least it's documented.
Is there a simple reason to return numeric objects from ceiling and floor ? If we were talking about inefficiencies due to repeated casting (which seems to be the case for integer division), I would expect class(ceiling(3L)) be "integer" , so what happens?
source share