Re: Base 2 and HEX
[Prev][Next][Index][Thread]
Re: Base 2 and HEX
As Ray Kremer points out, it is trivial to compute the base-2 log of a
number -- just divide the log ot the number to some base by the log of 2
to the same base. The problem with conversion to a display in binary or
hex is the real issue here.
How are numbers stored _internally_ in a TI calculator? I don't know,
exactly, but I expect in some form of binary representation. However,
all of the built-in display routines (except those called on the TI-86
when in binary or hex mode) take this representation and produce a
string of decimal digits on the screen. It is important not to think of
the stored number as consisting of these digits, though -- what is
needed is to somehow hihgjack the routines that are activated when a
simple call is made to display the stored variable, and do something
else to cause a custom display.
On the TI89/92 (the more flexible calculator), there is the capability
of displaying an _integer_ in a different base, as noted, by calling a
built-in function. But a the value of a logarithm is rarely an integer.
However, this is easily solved by breaking the value into an integer
part (which can be displayed immediately) and a fractional part, which
can be displayed to some desired precision by a simple strategy.
Given a number x between 0 and 1, the first n decimal digits of its
normal decimal expansion can be found by multiplying by 10^n (and
truncating or rounding, as desired). Analogously, the first n "binal"
digits of its binary expansion can be found by multiplying by 2^n,
truncating or rounding, and expressing the resulting integer in binary.
The same strategy works, with obvious modifications, to display a
fractional part in hex or in any other desired base. You just have to
know in advance the number of digits you want.
That's not a lot of work. I can't imagine that a simpler solution exists
in a palmtop environment.
RWW Taylor
National Technical Institute for the Deaf
Rochester Institute of Technology
Rochester NY 14623
>>>> The plural of mongoose begins with p. <<<<
******************************************************************
* To UNSUBSCRIBE, send an email TO: listserv@lists.ppp.ti.com
* with a message (not the subject) that reads SIGNOFF CALC-TI
*
* Archives at http://peach.ease.lsoft.com/archives/calc-ti.html
******************************************************************