Alright, I've decided to work on a String to Float parser in axe
. It is incomplete as of yet, but I need to get critical parts of the program finished as of yet. My current source code is as follows.
.NP
GetCalc("Str1")->A
{A-2}^^r^^r->E
0->{A+E}
[r2]->B
Disp A,[i]
0->C
0->D
If {A}=176
A+1->A
|E80->C
End
While {A}='0'
A+1->A
If length(A)=0
Goto EXIT
End
End
If {A}=58
A+1->A
~1->D
While {A}='0'
A+1->A
D-1->D
If length(A)=0
Goto EXIT
End
End
Else
inData(A,58)->D
If D=0
length(A)-2->D
Else
D-2->D
End:End
Disp D>Dec,[i]
|E80+D+C^^r^^r->C
Disp C>Hex
Lbl EXIT
As you can see, it doesn't(yet ) make any attempt to parse the numeric data in the string
. It parses negative numbers perfectly
, and it has no problem getting the 10^x value from integers.The problems start when you feed it a floating point number
. With a number with an integer part before the ".", it parses the thing as an integer, and returns the wrong value for the 10^x, as if it was not anticipating the decimal point, or not parsing it otherwise. What scares me, though, is when a number is parsed WITHOUT the integer part, it returns nothing at all
. Can I please see some assistance here, if possible?
I will post the source code and ti-basic lib version here when completed.
Edit-found the problem with the 0 decimal parsing - Misplaced end!
Still doesn't parse the floating point (ex. 12.345) correctly, though