Does FloatString.spin2 exist?
bestep
Posts: 3
I want to use the FloatToString method.
I am working on converting it to spin2, but wanted to check if that had already been done.
Comments
You should ask @cgracey about a Spin2 version of FloatToString as he knows all the tricks of Spin2/PASM2 and would make a very efficient object.
A while back I helped a friend with a project that uses a PC to send commands (as strings) to the P2. He asked if he could send floats (as strings) to the P2 and get them back. I created the attached object. Maybe it will be helpful. It's not fancy; it just handles the basics.
Thanks, Jon.
I was able to get the FloatToString code working in spin2.
I did run into a minor issue in the Setup function where the exponent is estimated. The original spin code was "exponent := ((single << 1 >> 24 - 127) * 77) ~> 8". I attempted to convert it to "exponent :=((single << 1 >> 24 - 127) * 77) sar 8" but this did not work properly and would cause the function to fail. However, if I set it to an integer value like "exponent := 4", then all is well and floats are converted to strings.
Am I converting that line incorrectly?
It looks correct to me. Another way you could do it in the P2 is
Jon,
Your suggestion worked. The updated FloatToString code is attached. I will add to the OBEX.