> So J is saying that the floor of infinity is infinity (and the ceiling of
> infinity is also infinity). Since infinity is not a number, it would seem
> that an error should be generated when taking the floor of infinity, or
> perhaps NAN, or a zero? In any case, this messes up my nice integer-finding
> verb. Is the\re a mathematical justification for defining the floor of
> infinity to be infinity?
> Https://math.stackexchange.com/questions/981708/limit-of-floor-function-when-x-goes-infinity

       (#~0=(-<.)) 1 2.5 3 4.5 6
    1 3 6
       (#~0=(-<.)) 1 2.5 _ 3 4.5 6
   |NaN Error
   |       (#~0=(-<.))1 2.5 _ 3 4.5 6

Though I would be wary of floating point comparison issues unless you have good
reason to believe this isn't a problem.

If you want a "mathematical" definition that motivates (_=<._), then let us
define the floor function as follows:

    Let <. : R+ -> Z+ where (<.r) is defined to be the extended integer such
    that there exists a real number s in the interval [0,1) and ((<.r)=|s-r).

Restricting just to the real numbers, this corresponds to the standard floor
function, so it's arguably a reasonable generalization. Maybe a better
argument is to convince yourself this is what makes sense with how IEEE
floating points are represented. Or maybe you could check out the Complex Floor
paper [0] and just rest assured that the floor function has been given a lot of
design thought.

[0]:https://www.jsoftware.com/papers/eem/complexfloor.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to