Shop OBEX P1 Docs P2 Docs Learn Events
Draw Floating Point Numbers to TV Using Graphics Object? — Parallax Forums

Draw Floating Point Numbers to TV Using Graphics Object?

edited 2007-11-01 21:39 in Propeller 1
I am using the FloatMath.spin object to calculate floating point numbers.
I am using the Graphics, Numbers, and TV Object to draw a video out.
When I want to draw text to the Screen, I use:

gr.text(-90,70, String("DMC"))

or numbers to the screen, I use:

gr.text( 60, 90, Num.ToStr( stored[noparse][[/noparse]Temp], Num#DDEC))

When I want to draw Floating Point Numbers to the screen,
I want the screen to print values from 0.00 to 4.25, showing the decimal.
I can calculate them using:

f.FAdd( 2.1 , 3.4 )

but I have no way to convert it to a string for sending to the graphics object.

Can anyone help me out? Do I need to write a f.ToStr() function into the FloatMath object?


Thanks!

-Ryan Brandys

Comments

  • Harrison.Harrison. Posts: 484
    edited 2007-10-31 02:33
    Take a look at the FloatString.spin object provided with the Propeller Tool. It contains floating point to string conversion functions that you are looking for.

    f  : "FloatMath"
    fs : "FloatString"
    
    ----
    
    gr.text(60, 90, fs.FloatToString(f.FAdd(2.1, 3.4)))
    
    



    Harrison
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-31 02:49
    FloatMath is a "feasibility study" and of use only for the least demanding applications, and the rare cases where you have to trade speed for a COG..
    You normally use Float32, which is about 200 times faster..
    However you need a trick to use Float32 and FloatString in harmony.. See the corresponding threads and there is also a first Q&A entry on this matter...
  • edited 2007-11-01 02:02
    I tried adding a FloatString object and now my top level object will not compile. it tells me "object exceeds runtime memory limit by 153 longs"

    When I take FloatString back out, recompile myprogram, and look at the memory table, I have 6,261 longs free. My program is very small.

    Since FloatString is only 368 longs, why does it tell me I am out of memory?

    Thanks.
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-01 21:39
    You most likely have a funny _stack setting...
Sign In or Register to comment.