Omnimaga

Calculator Community => Discontinued => Major Community Projects => Correlation => Topic started by: Runer112 on April 10, 2011, 11:01:27 am

Title: TI Float to String Routine
Post by: Runer112 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.
Title: Re: TI Float to String Routine
Post by: Hot_Dog on April 10, 2011, 11:03:43 am
This will be great!  Thanks, Runer112!