Shop OBEX P1 Docs P2 Docs Learn Events
Formatted Float ???? — Parallax Forums

Formatted Float ????

Brian RileyBrian Riley Posts: 626
edited 2010-01-13 05:07 in Propeller 1
Has anybody got any code to control the string display of a float for fixed length display of data? I have tried all sorts of search strings in OBEX and the forum and the only mention at all was a sour grapes response to Peter Verkaik's sprintf/sscanf object because it did NOT handle float.

cheers ... BBR

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
The Shoppe at Wulfden
www.wulfden.org/TheShoppe/

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2010-01-12 20:07
    Isn't this what you are looking for:

    http://obex.parallax.com/objects/20/
  • VIRANDVIRAND Posts: 656
    edited 2010-01-13 00:01
    Except for rounding, it seems to me that fixed float (NOT interpreted as "money and pennies" math) has easy rules about
    where the decimal point goes and the signs of the numbers, otherwise to me its the same as integer math. What is non-fixed
    float... arbitrary precision?
  • Brian RileyBrian Riley Posts: 626
    edited 2010-01-13 05:07
    localroger said...
    Isn't this what you are looking for:

    http://obex.parallax.com/objects/20/


    D'uh .... I already have that. Its the updated one where FloatToFormat was added. OK, I am back on track.

    I had found that manipulating precision and commenting out the 'trim trailing zeros' code let me have some control, but this is a lot cleaner.

    The FloatToFormat is limited to nine places, but that is more than adequate for the data I need to display. I did find a comment by someone who wanted to display GPS data (long/lat) in degrees and decimal degrees to 6 decimal places and would need more than 9 which should be a simple mod.

    Thanks ... cheers ... BBR

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cheers ... brian riley, n1bq, underhill center, vermont
    The Shoppe at Wulfden
    www.wulfden.org/TheShoppe/
Sign In or Register to comment.