How can I display numbers with decimals?
Flotul
Posts: 24
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)
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
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
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Roger
Savigny, SWITZERLAND (french speaking part)
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
And, I will add, APPERANTLY I didn't express it as well as Jon Williams did, I appoligize for that.
(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
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)
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
·