Pikir dan Rasa

cogito ergo sum

Contoh sederhana right shift pada Arduino [pastebin]

leave a comment »

Uji sederhana right shift pada Arduino.

 

/*

 */

void setup() {
 
  Serial.begin(9600);
   
  byte vara=0b10000000;
  
  Serial.print("Sebelum shift: ");
  Serial.println(vara,BIN);
  Serial.println(vara,DEC);
  
  vara>>=3;

  Serial.print("Sesudah shift: ");
  Serial.println(vara,BIN);
  Serial.println(vara,DEC);
  
  
  //signed int vara2=0b11000000;
  signed char vara2=-16;
  
  Serial.print("Sebelum shift: ");
  Serial.println(vara2,BIN);
  Serial.println(vara2,DEC);
  
  vara2>>=2;

  Serial.print("Sesudah shift: ");
  Serial.println(vara2,BIN);
  Serial.println(vara2,DEC);

}

void loop() { 
}

 

 

http://pastebin.com/embed_iframe.php?i=FDCwg1WC

Written by sunupradana

February 16, 2012 at 5:42 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: