Thread: shifting? division?

  1. #1
    Registered User
    Join Date
    Aug 2009

    shifting? division?

    I was hoping someone could maybe write an example to better explain to me this idea. i know its true but I'm having a hard time understanding it,
    so its possible to shift a value and by shifting the value its basically like dividing it by a power of 2?? i think or something like that can someone explain by giving an example on how that really works in a C program.

  2. #2
    Registered User jimtuv's Avatar
    Join Date
    May 2010
    Sylvania, Ohio
    consider the following in binary.

    0001 = 1 decimal

    0010 = 2 decimal

    0100 = 4 decimal

    1000 = 8 decimal

    10000 = 16 decimal

    100000 = 32 decimal

    see how as the bit shifts to the left the number is multiplied by 2 each move. Division by 2 is just a shift to the right. Also you could read this
    Last edited by jimtuv; 06-09-2010 at 02:10 PM.

  3. #3
    Registered User
    Join Date
    Aug 2009
    okay so if its

    00101110 and i shift it
    >> 3;
    wiil that divivde the binary by 8

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    Yep. It will divide the decimal number by 8.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Get jiffies?
    By pgzh in forum Linux Programming
    Replies: 6
    Last Post: 03-17-2008, 10:30 AM
  2. pseudo code for division
    By svaidya in forum C Programming
    Replies: 14
    Last Post: 05-31-2007, 01:48 PM
  3. modulo 2 division question help
    By shaq8u in forum C Programming
    Replies: 9
    Last Post: 08-20-2003, 08:37 AM
  4. shifting numbers
    By kurz7 in forum C Programming
    Replies: 1
    Last Post: 08-06-2003, 12:38 PM
  5. Modular Division problem
    By Malek in forum C++ Programming
    Replies: 7
    Last Post: 05-24-2003, 06:08 PM