Shop OBEX P1 Docs P2 Docs Learn Events
Simple (I hope) problem with FloatString — Parallax Forums

Simple (I hope) problem with FloatString

derekfderekf Posts: 3
edited 2013-11-21 18:46 in Propeller 1
I don't know what I have changed.

This is about as simple of a floating point test program as I can come up with:
CON
   
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
   
OBJ
   
  pst : "Parallax Serial Terminal"
  f : "Float32"
  fs : "FloatString"  


PUB test3 | fa, fb


f.Start
pst.Start(115_200)
pst.Str(String("Starting."))
pst.NewLine 
fa := f.FFloat(5)                                                                              
fb := f.FDiv(fa, 2.0)             
pst.Str(fs.FloatToString(fb))
pst.NewLine   
pst.Str(String("Ending."))

It has worked in the past. I've seen it. It showed me "2.5" as pretty as you please, and I called it good... and then when I tried to build something useful using it, it stopped working there and also stopped working here. Now it gets hung up at the FloatToString and never shows a value there nor gets to the "Ending" text.

I've replaced my copy of FloatString with the v1.2 from http://obex.parallax.com/object/236 and it didn't help. I am using Float32 in the FloatString instead of FloatMath. I'm sure it's something simple but I've been bouncing my head off this for a couple of days and it's time to ask folks who know things. Can any of y'all point me in the right direction?

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-11-21 17:18
    Odd. This works for me out of the box (with objects included in the PropTool library). Can you archive and attach your code?
    I am using Float32 in the FloatString instead of FloatMath.
    Are you starting this object (on demand)? Since FloatString itself doesn't feature a start method it's the most likely cause.
  • derekfderekf Posts: 3
    edited 2013-11-21 17:30
    Float32 Usage Test.zip

    Thank you for taking a look at this.
  • kuronekokuroneko Posts: 3,623
    edited 2013-11-21 17:42
    As I thought, you need to start Float32 within FloatString, e.g. in any method you call you'd need something like
    ifnot started
        started := F.start
    
    started is a global variable.
  • derekfderekf Posts: 3
    edited 2013-11-21 17:50
    That's the darndest thing. All the functions in FloatString seem to call Setup(single) so I put it there... and it works!

    Thank you, kuroneko. I don't know why it worked for me before and then stopped... but now it works again and I appreciate it!
  • kuronekokuroneko Posts: 3,623
    edited 2013-11-21 18:46
    derekf wrote: »
    I don't know why it worked for me before and then stopped...
    The original version used FloatMath which doesn't need to be started (in-place processing). After the change you were left with an uninitialised (i.e. non-working) Float32. HTH
Sign In or Register to comment.