Find jobs | Jobseekers
Employer login
About us Sitemap of www.CareerRide.com Sitemap FAQ related with www.CareerRide.com FAQ Click here to Contact us Contact
       
Submit Resume Free ! | Access Resume Free !
Home Career Services Resume Services Interview questions Articles Books

C Bit Operations


C Bit Operations: Interview Questions

<<Previous  Next>>

C Bit Operations - August 06, 2008 at 13:10 PM by Amit Satpute

What are bitwise shift operators?

Answer
<< - Bitwise Left-Shift
Bitwise Left-Shift is useful when to want to MULTIPLY an integer (not floating point numbers) by a power of 2.
Expression: a << b
This expression returns the value of a multiplied by 2 to the power of b.

>> - Bitwise Right-Shift
Bitwise Right-Shift does the opposite, and takes away bits on the right.
Expression: a >> b
This expression returns the value of a divided by 2 to the power of b.

Explain the use of bit fieild.

Answer
Bit Fields allow the packing of data in a structure.

This is especially useful when memory or data storage is at a premium

The maximum length of the field should be less than or equal to the integer word length of the computer.some compilers may allow memory overlap for the fields.Some store the next field in the next word.
C lets us do this in a structure definition by putting :bit length after the variable:
struct pack
{
        unsigned int funny_int:9;
}p;

Also, Boolean datatype flags can be stored compactly as a series of bits using the bits fields. Each Boolean flag is stored in a separate bit..


<<Previous  Next>>

  1. Describe bitwise shift operators.
  2. Define bit fields.



 
Today's Hot Jobs
C++  SQL Server
.NET  Java  Oracle
Finance  Marketing
Seekers  Employers
Copyright © 2008 CareerRide.com. All rights reserved.