Shop OBEX P1 Docs P2 Docs Learn Events
How can I display numbers with decimals? — Parallax Forums

How can I display numbers with decimals?

FlotulFlotul Posts: 24
edited 2006-03-23 20:58 in General Discussion
Hello,

This is a peace of code I have found to display numbers with decimals. Actually, it displays "1.234".

How do I have to handle this to display, for example, "12.34" or "123.4"?

' {$STAMP BS2}
' {$PBASIC 2.5}

Nombre VAR Word
Nombre = 1234

DEBUG HOME, "Nombre : ", DEC Nombre DIG 3, ".", DEC3 Nombre

END

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Roger

Savigny, SWITZERLAND (french speaking part)

Comments

  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-23 17:04
    Flotul...
    The help file says DEC {1~5} to display the number of decimal places...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • FlotulFlotul Posts: 24
    edited 2006-03-23 17:38
    I tried and you apparently didn't ;-)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger

    Savigny, SWITZERLAND (french speaking part)
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-23 17:52
    Here's how:

    x.xxxx

    · DEBUG DEC (xVal / 10000), ".", DEC4 xVal


    _x.xxx

    · DEBUG DEC (xVal / 1000), ".", DEC3 xVal


    __x.xx

    · DEBUG DEC (xVal / 100), ".", DEC2 xVal


    ___x.x

    · DEBUG DEC (xVal / 10), ".", DEC1 xVal

    ·
    Note that the _ character indicates that a digit may or may not be there, depending on the size of xVal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-23 18:18
    ··· APPERENTLY you will need to change how·you replie to people next time because APPERANTLY I found it QUITE irrating to read your reply.· Little things like ;-) dont make up for·disrespect.

    And, I will add, APPERANTLY I didn't express it as well as Jon Williams did, I appoligize for that.
    Flotul said...
    I tried and you apparently didn't ;-)

    (I edited this post because it's not in the correct "form")...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK


    Post Edited (Kaos Kidd) : 3/23/2006 6:33:40 PM GMT
  • FlotulFlotul Posts: 24
    edited 2006-03-23 20:15
    Sorry KK,

    I didn't ment to be unpolite with you in anyway.

    Before I opened this topic, I read lots of documents, help files and I have been trying to sort out the problem by myself.

    So, when I saw your very quick reply and what you were proposing, I found that this was what I had already done some time ago.

    You where right, but I couldn't understand it the way you have replied. Jon's explanation is far more clear to me than yours.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger

    Savigny, SWITZERLAND (french speaking part)
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-23 20:58
    Roger.
    It's cool... I'm glad it's working for you.
    Jon is great with it comes to explaining things...

    Fred

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
Sign In or Register to comment.