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 support@ccsinfo.com

x>>15

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



Joined: 10 Aug 2009
Posts: 6

View user's profile Send private message

x>>15
PostPosted: Sun Aug 23, 2009 12:56 pm     Reply with quote

What is the best code in CCS for the instruction x>>15?
Ttelmah
Guest







PostPosted: Sun Aug 23, 2009 1:55 pm     Reply with quote

Probably depends on how large the data is.
For 16bit data, it'd probably be faster to just perform a bit test, on the top bit, and just output the result of this (0/1).
For larger data types, you really have no choice but to use the shift.

Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Aug 24, 2009 12:36 am     Reply with quote

Code:
unsigned int16 var;
unsigned int8 x;

var = 0x8000;

x = make8 ( var, 1);

if (x & 0x80) {
    do something;
} else {
    do something else;
}

also works is:
Code:

if (var & 0x8000) {
  do something;
}

_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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