Author Topic: TI Float to String Routine  (Read 6497 times)

0 Members and 1 Guest are viewing this topic.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
TI Float to String Routine
« on: April 10, 2011, 11:01:27 am »
I've been waiting for you to show up in IRC since Friday so I could give you this routine, but since I haven't seen you yet there, here it is! It returns strings like the OS would when displaying numbers on the home screen with the Float setting. It perfectly mimics the OS routine for every reasonable input I've tried, even when using hacked float variables that have exponents above 99. The only thing it doesn't perfectly mimic is hacked floats that contain invalid hexadecimal characters. But that shouldn't happen too often.

Anyway, you said you wanted this for speed. Good news! The OS routine appears to take an average of about 5500 cycles in my tests, whereas my routine takes an average of about 1600 cycles. It'll cost you 244 bytes, but the choice is yours.

And anyone besides Hot_Dog, feel free to grab this routine as well. Note though, that because I made this routine to Hot_Dog's specifications, it has a few weird quirks. The location of the string returned has to be a constant, but you can change that. Right now it's set to OP4. You'll also probably want to get rid of the ld (hl),20 \ inc l at the start of the routine, another weird quirk Hot_Dog said he needed. Also, note that the string returned is a null-terminated string of tokens, not characters. You should be able to change this though by simply changing all the token values in the routine to ASCII values.
« Last Edit: April 10, 2011, 11:17:48 am by Runer112 »

Offline Hot_Dog

  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: TI Float to String Routine
« Reply #1 on: April 10, 2011, 11:03:43 am »
This will be great!  Thanks, Runer112!