A89: Re: Displaying numbers


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

A89: Re: Displaying numbers




> Really, really, really dumb question:  What's the easiest way to display a
> number (in a register or variable) in decimal form?  I figured out how to do
> it in hexadecimal or binary, but that's not too useful in a game.  Don't ask
> me how I went without knowing how to do this... I guess I just never needed
> to before. Thanks.

There are a few ways...
* The most flexible (but also the slowest) way is to use sprintf().
* You can use the built-in BCD functions (or make your own). They basically deal
with hexadecimal numbers but don't use A-F, so a normal register can contain
0000-9999. Then you just use whatever way of printing hexadecimal you want.
* The last one is to write your own routine for plotting a hex number as a
decimal. The easiest (but not fastest) way is to repeatedly divide by 10 and
write the remainder to a string until the division becomes zero.

 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF Quote follows:

Mrs. Nugent was the Johnson's next door neighbour, and known to be
unreasonable on subjects like Madonna played at full volume at 3 a.m.
        -- (Terry Pratchett, Johnny and the dead)





References: