Advertisement
sunu

arduino_shift_right01

Feb 16th, 2012
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. */
  4.  
  5. void setup() {
  6.  
  7. Serial.begin(9600);
  8.  
  9. byte vara=0b10000000;
  10.  
  11. Serial.print("Sebelum shift: ");
  12. Serial.println(vara,BIN);
  13. Serial.println(vara,DEC);
  14.  
  15. vara>>=3;
  16.  
  17. Serial.print("Sesudah shift: ");
  18. Serial.println(vara,BIN);
  19. Serial.println(vara,DEC);
  20.  
  21.  
  22. //signed int vara2=0b11000000;
  23. signed char vara2=-16;
  24.  
  25. Serial.print("Sebelum shift: ");
  26. Serial.println(vara2,BIN);
  27. Serial.println(vara2,DEC);
  28.  
  29. vara2>>=2;
  30.  
  31. Serial.print("Sesudah shift: ");
  32. Serial.println(vara2,BIN);
  33. Serial.println(vara2,DEC);
  34. }
  35.  
  36. void loop() {
  37.  
  38. }
Advertisement
RAW Paste Data Copied
Advertisement