Re: TI Floor vs. Int


[Prev][Next][Index][Thread]

Re: TI Floor vs. Int



Justin Smith wrote:
>
>    Int and Floor seem to do the same thing to me.
>
> Any ideas if they are different or the same?
>
> Like maybe one example of when I'd use floor, and an example of when I'd
> use int?

The TI-92 manual clearly states that the two are identical.
Problem is that the implementation if int() is different from system to
system (a nuisance to C programmers :)
Ideally, this is how they should work (IMNSHO):

ceiling(x) - gives you the smallest integer >= x

int(x) - returns the integer part of your x, i.e. throws away everything
behind the comma.

floor(x) - gives you the largest integer <= x

TI has implemented int() to be identical to floor(). Why, I do not know,
but I think it's ridiculous to have two identical functions. Someone
should have thought "DUH!" when they wrote in the manual that these
functions were indeed identical.

To give you a complete overview[1], we can take a look at the five
incidences that have interest, namely positive decimal, positive
integer, zero, negative integer, and negative decimal:
ce(x) = ceiling(x)
TI(x) = TI's implementation of int(x)
fl(x) = floor(x)
my(x) = int(x) as I would like it to be :)

|  x  | ce(x) | TI(x) | fl(x) | my(x) |
|-----+-------+-------+-------+-------|
| 2.5 |   3.  |   2.  |   2.  |   2.  |
|  2  |   2   |   2   |   2   |   2   |
|  0  |   0   |   0   |   0   |   0   |
| -2  |  -2   |  -2   |  -2   |  -2   |
|-2.5 |  -2.  |  -3.  |  -3.  |  -2   |
|-----+-------+-------+-------+-------|

As you can see here, the only difference in TI(x) and my(x) is when
dealing with negative decimal numbers. A small difference, but still a
significant one, if you ask me (or my friend here, who agrees :)

HTH. HAND.

[1] Normally I don't do ASCII diagrams because I know how annoying they
are[2] when you don't use a mono-spaced font, but I'll do this one
anyway :P

[2] And not at all helpful.

--
          Rene Kragh Pedersen
------------------------------------------------------------------
(2) When joining the two chain ends, the closing spring is to be
pressed in, but in no other way than contrary to the running direction
of the chain in the two closing grooves.


Follow-Ups: References: