# TI-BASIC:Number To String

**Routine Summary**

Converts a real number to a string.

**Inputs**

*N* - the number you want to convert

**Outputs**

*Str1* - the number N in string form

**Variables Used**

L₁, L₂, Y₁, Str1, N

**Calculator Compatibility**

TI-83/84/+/SE

**Download**

:{0,1→L₁ :{0,N→L₂ :LinReg(ax+b) Y₁ :Equ►String(Y₁,Str1 :sub(Str1,1,length(Str1)-3→Str1

This code works because it creates two points with a known best fit line: the best fit line through (0,0) and (1,N) is y=Nx+0. LinReg(ax+b) calculates this best fit line, and stores its equation to Y₁.

Then, we use Equ►String( to store this equation to Str1, which now contains "NX+0" with N replaced by the numerical value of N. After that, the Sub( command get rids of the "X+0" at the end, leaving only the string representation of N.

This routine uses L₁, L₂, and Y₁, so you should clean up those variables at the end of your program. If you're working with the graph screen in function mode, storing to Y₁ can be a problem since it will draw an unwanted line through your graphics. Use r₁ instead but make sure the calculator isn't in polar mode.

**Note:** This only works for real numbers. With complex numbers, such as imaginary numbers, you can use this code at the end of the first to get the same effect with *i* in it.

:Str1+"i"→Str1