CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

suppress leading zero's on lcd

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
da21



Joined: 22 Oct 2003
Posts: 1
Location: UK

View user's profile Send private message

suppress leading zero's on lcd
PostPosted: Fri Aug 04, 2006 8:46 am     Reply with quote

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







PostPosted: Fri Aug 04, 2006 9:14 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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