64 Bitwise AND

This is a discussion on 64 Bitwise AND within the C++ Programming forums, part of the General Programming Boards category; I am completely lost... Why is tmpi always 0? It works just fine when using 32 bit ints. I am ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    1

    64 Bitwise AND

    I am completely lost... Why is tmpi always 0? It works just fine when using 32 bit ints. I am compiling the project in Visual Studio 2008 in 64 bit release mode and running it on a quad core machine with 64 bit vista. Shift operations seem to work just fine .

    Code:
    typedef unsigned __int64 uint64;
    
    uint64 tmpc= 16,tmpe=  13,tmpD= 12, tmpi=5;
    
     tmpi= tmpc &  tmpe;
    
    printf ("tmpi = %I64d \n", tmpi);

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,304
    Quote Originally Posted by Lostsheep View Post
    I am completely lost... Why is tmpi always 0? It works just fine when using 32 bit ints. I am compiling the project in Visual Studio 2008 in 64 bit release mode and running it on a quad core machine with 64 bit vista. Shift operations seem to work just fine .

    Code:
    typedef unsigned __int64 uint64;
    
    uint64 tmpc= 16,tmpe=  13,tmpD= 12, tmpi=5;
    
     tmpi= tmpc &  tmpe;
    
    printf ("tmpi = %I64d \n", tmpi);
    What do you mean "works fine when using 32 bit ints"? It will correctly give zero regardless of the size of the integer you use, because 16 (10000 in binary) and 13 (1101 in binary) is zero:
    Code:
      10000
    & 01101
    -------
      00000
    Last edited by iMalc; 06-14-2008 at 10:04 PM.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    i've lost my mind
    Join Date
    Jun 2008
    Posts
    26
    this is exactly why i still love my notebook and pencil

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 64 bit testing
    By DrSnuggles in forum C++ Programming
    Replies: 7
    Last Post: 11-20-2007, 02:20 AM
  2. File IO
    By Jack1982 in forum C++ Programming
    Replies: 9
    Last Post: 10-15-2007, 01:14 AM
  3. c++ bitwise operators with 64 bit integers? possible?
    By chrisd1100 in forum C++ Programming
    Replies: 8
    Last Post: 09-04-2007, 07:13 PM
  4. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 07:02 PM
  5. If the RGB color is (64, 64, 255), change it to (64, 255, 64).
    By Grayson_Peddie in forum C# Programming
    Replies: 2
    Last Post: 06-14-2003, 04:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21