|
|
View previous topic :: View next topic |
Author |
Message |
da21
Joined: 22 Oct 2003 Posts: 1 Location: UK
|
suppress leading zero's on lcd |
Posted: Fri Aug 04, 2006 8:46 am |
|
|
Hi all ,
i am trying to suppress leading zero's on a thermometer application using a standard LCD display , i thought this should work but i get a
'constant out of the valid range ' -16 is not 0..255 error
i am sure i have used this on an older version of the compiler before
boolean zero;
if (!num && zero) // blank zero's if previous was zero
{
num = ' ' - '0'; ?? error on this line
}
any idea of a fix |
|
|
Ttelmah Guest
|
|
Posted: Fri Aug 04, 2006 9:14 am |
|
|
Surely, if you just want to blank the digit, the line wants to just read:
num=' ';
As it stands, you are taking ASCII 'space' (=32), and subtracting ASCII '0' (=48).
If you do want to put '-16' into the num value, you can do it with:
num=(int8)(' '-'0');
It'll actually be stored as '0xF0', which will behave like -16, if arithmetic is performed on it (add 16 to get 0 etc.).
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|