Thread: bitwise operations

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    2

    bitwise operations

    Gday, I was wondering whether someone can help.

    I need to perform shifts and bitwise operations on 64bits. I am trying to shift bits on a double type - 8 bytes. I think the problem lies in the fact that a machine word is 4 bytes. The following code seems to compile ok

    double mask = 1 << 31;

    but when i try something like this

    double a, temp;

    temp = mask & a;

    i get an error something like: illegal operation on binary &.

    Can anyone suggest a fix, perhaps some pointers on shifting bits between machine worsds.

    cheers, Andrew.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You cannot use bitwise operands on floating point variables.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    2
    Thanks, i hadn't considered that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitwise Operations to Read ON/OFF Bits
    By pseudonoma in forum C Programming
    Replies: 4
    Last Post: 02-25-2008, 03:15 PM
  2. bitwise operations with double
    By henry_kay in forum C Programming
    Replies: 2
    Last Post: 10-03-2007, 04:57 AM
  3. Bitwise operations
    By sh3rpa in forum C++ Programming
    Replies: 16
    Last Post: 09-25-2007, 06:32 PM
  4. bitwise operations
    By black_watch in forum C++ Programming
    Replies: 9
    Last Post: 03-24-2007, 04:48 AM
  5. bitwise operations
    By bukko in forum C Programming
    Replies: 3
    Last Post: 10-06-2001, 06:56 AM