Bit stuck here ! .... I have an INT variable ... it can only be 0 to 9999, but I want to display it as 0.000 to 9.999
How do I output it to the LCD in this format ?
Decimal Point in LCD
Moderator: Benj
-
iain wilkie
- Posts: 97
- Joined: Tue Jul 14, 2009 4:37 pm
- Has thanked: 13 times
- Been thanked: 9 times
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: Decimal Point in LCD
One easy way is to convert the interger to a string
Split using left$ and right $
Print string onthe LCD Int part, print a "." then print the decimal
Ive attached a very simple exmple of how to manipulate strings.
I suppose the other way would be to convert to a float and then divide by 10 or 100 ect .
But then you would still have to convert float to string to display on the lcd
Hope this helps
Split using left$ and right $
Print string onthe LCD Int part, print a "." then print the decimal
Ive attached a very simple exmple of how to manipulate strings.
I suppose the other way would be to convert to a float and then divide by 10 or 100 ect .
But then you would still have to convert float to string to display on the lcd
Hope this helps
- Attachments
-
- split string.fcf
- (6.5 KiB) Downloaded 411 times
1 in 10 people understand binary, the other one doesn't !
-
iain wilkie
- Posts: 97
- Joined: Tue Jul 14, 2009 4:37 pm
- Has thanked: 13 times
- Been thanked: 9 times
Re: Decimal Point in LCD
That works fine for numbers like 1234 but a nuber like 55 needs to display as 0.055 ....
Iain
Iain
- Dan81
- Valued Contributor

- Posts: 268
- Joined: Sun Jan 15, 2006 4:07 pm
- Location: Albi France
- Been thanked: 60 times
- Contact:
Re: Decimal Point in LCD
Hello Iain
In a calculation :
TH = N DIV 1000
var = N MOD 1000
HND = var DIV 100
var = var MOD 100
TEN = var DIV 10
UNT = var MOD 10
then
PRINT_NUMBER (TH)
PRINT_ASCII (',')
PRINT_NUMBER (HND)
PRINT_NUMBER (TEN)
PRINT_NUMBER (UNT)
Daniel
In a calculation :
TH = N DIV 1000
var = N MOD 1000
HND = var DIV 100
var = var MOD 100
TEN = var DIV 10
UNT = var MOD 10
then
PRINT_NUMBER (TH)
PRINT_ASCII (',')
PRINT_NUMBER (HND)
PRINT_NUMBER (TEN)
PRINT_NUMBER (UNT)
Daniel
-
iain wilkie
- Posts: 97
- Joined: Tue Jul 14, 2009 4:37 pm
- Has thanked: 13 times
- Been thanked: 9 times
Re: Decimal Point in LCD
Thanks guys ... found another solution,
The max value is 9999 so all I do is add 10000 to the value so I know it will always be 5 digits.
Then int = mid$(val,1,1)
and dec = right$(val,3)
Then just output to lcd int "." dec
Cheers
The max value is 9999 so all I do is add 10000 to the value so I know it will always be 5 digits.
Then int = mid$(val,1,1)
and dec = right$(val,3)
Then just output to lcd int "." dec
Cheers