Explain the shift operators, C/C++ Programming

Assignment Help:

The Shift Operators

There are 2 shift operators : left shift ( <<) and right shift (>>). These are binary operators. The format is

                operand >> number or operand << number

 

The first operand is the value, which is to be shifted. The second is the number of bits by which it is shifted. The left shift operators shift 'number' bits to the left, while the right shift operators shift 'number' bits to the right. The leftmost and the rightmost bits are shifted out and are lost.

e.g.

char x, y = 0x80;

                y = y >> 3;

                x = y <<2;

                y <<= 1;

                x >>=2;

The char y( which is allocated a byte of space on a 16-bit machine) will have its bits shifted to the right three places. The value of y which was 0x80(1000 0000) is changed to 0xFo (1111 0000) , after y = y>>3.

 


Related Discussions:- Explain the shift operators

Describe run-time type identification, The ability to verify at run time th...

The ability to verify at run time the type of an object by using the typed operator or the dynamic_cast operator.

Padovan string, padovan string problem program 1 : package test.padovan...

padovan string problem program 1 : package test.padovanstring; public class PadovanString {     public int stringOccurrences(int n, String str){        if(n >= 40)

Serial programming, Hi I''m trying to connect to CISCO router using termios...

Hi I''m trying to connect to CISCO router using termios. So I decided to have two threads one for reading data and the other one for writing data. The problem is that I have to add

Circular linked list assignment, need an expert programmer to finish coding...

need an expert programmer to finish coding the requirements from the assignment withen 4 hrs

Structured design of programs, Within software engineering, software is ver...

Within software engineering, software is very rarely written by a single software engineer. Usually a team of engineers write a program; therefore a formal structural design approa

C++, how do i write a c++ program that will input a number and output its f...

how do i write a c++ program that will input a number and output its factorial using the while loop

Create a album using multi-dimensional arrays, Create a Document that show ...

Create a Document that show information about albums. First create a paragraph or two about the purpose of the page and your interests in music: genres, styles, etc. Next have a

Padovan string, write a javaprogram to solve padovan string using java? ...

write a javaprogram to solve padovan string using java? program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring;

Write a program to calculate the timetable, Write a program to calculate th...

Write a program to calculate the timetable for numbers 1 -> 10 and display them as follows. Your solution should use for do loops      #include stdio.h void main() {    char p

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd