Decimal to String
UBERhelp1 10 Jan 2019 00:46
Some background: Currently I'm working on a program that needs to convert a decimal to a string. There are restrictions, however. The decimal is contained in one 'cell' of a list. I want that to turn into letters/numbers/symbols.
For example, the decimal 0.010203 would become ABC by the following:
- decimal multiplied by 100, integer part (iPart) stored in variable I
- decimal multiplied by 100, decimal part (fPart) stored back in the list
- value of I is matched up with a letter/symbol/number, stored in a string (numbers 1-26 are A-Z, then 27=_, 28=., 29=,, and 30-39=1-9, and 40=?)
- repeats until I=0.
- Outputs entire string
Currently, the code I have is:
100(iPart(⸤FLASH(1→I
100(fPart(⸤FLASH(1→⸤FLASH(1
But I don't know how to convert the decimal to a string at that point. The list>string routines use the whole list, not just one cell. I was thinking it might be possible to have a separate list that, as the loop of the above code repeats, each integer gets stored. For example:
1→I
1→A
Repeat I=0
100(iPart(⸤FLASH(1→I
100(fPart(⸤FLASH(1→⸤FLASH(1
I→⸤CODE(A
A+1→A
End
//then the list>string routine
But I don't think this will be the most optimized/fastest way to do this (Speed is a necessity in this program).
Any thoughts, fixes, ideas appreciated.
Thanks,
UBER
🧟Initiating Project Horde 🧟