Re: Base conversion function FOR TI-92 (oops!)


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

Re: Base conversion function FOR TI-92 (oops!)



I forgot to mention that it's for the 92. Whoops! :)

William M. wrote in message <35231f16.0@news.ghgcorp.com>...
>I wrote a function to perform decimal conversions to (almost) any base.
>It's called base().  When you call base(nn,bb), nn is the number to be
>converted, and bb is the desired base.  Base 2=binary, base 8=octal, and
>base 16=hexadecimal.
>
>It's does no error checking, and there's probably a more efficient way of
>doing it, but hey, that's alright.  I just hope I typed it in right...
>
>To begin entering it, press Apps/Program Editor/New.  Change the Type to
>Function, and call the Variable "base" (w/o quotes).  At the top of the
>function, change "base()" to read "base(nn,bb)".
>
>Note that the "->" is symbol is created by pressing the "STO>" key.
>
>-----
>base(nn,bb)
>func
>local s, ch, num
>""->s
>while nn>=bb
>  mod(nn,bb)->num
>  string(num)->ch
>  if num>9 then
>    char(num-10+ord("a"))->ch
>  endif
>  ch&s->s
>  int(nn/bb)->nn
>endwhile
>
>string(nn)->ch
>if nn>9 then
>  char(nn-10+ord("a"))->ch
>endif
> ch&s->s
>
>return s
>
>endfunc
>-----
>
>


References: