Thread: Bitmask (example from The Audio Programming Book pg 22)

  1. #1
    Registered User Fauveboy's Avatar
    Join Date
    Apr 2014
    Posts
    42

    Bitmask (example from The Audio Programming Book pg 22)

    I think I'm getting confused by the use of Hexadecimal values...I do not understand what bitmasking is with this example? I can't see whats happening as a result of the code to demonstrate this feature. Can someone explain what Bitmasking is and how this following code represents that? is it ( going from the right of hexadecimal ) values comparing 0 & 1, then 0 & 1, then F & 1 (is F & 1 = the "1" in 0x0100, which is the result that prints out)? ect....?

    Code:
      short mask = 0xFF00, value, masked;
        value = 0x0111;
        masked = mask & value;
        
        printf("bitmask: %#x \n\n", masked);
    Last edited by Fauveboy; 01-02-2018 at 03:41 PM.

  2. #2
    Registered User Fauveboy's Avatar
    Join Date
    Apr 2014
    Posts
    42
    ...a single hexadecimal value, by isolating one such as 0xF(F, the "F" here)00, is represented by four bits?...is that global for all computers? how would to book know to demonstrate the 0xFF00 as 1111 1111 0000 0000 ? that might vary on a different machine? and also why is the 0x not represented in the binery ?

  3. #3
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    Hex is just the base-16 number system, so it's the same for all machines and each hex digit is shorthand for 4 bits.
    A little inaccuracy saves tons of explanation. - H.H. Munro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Audio programming
    By sridharval in forum C++ Programming
    Replies: 2
    Last Post: 06-25-2010, 07:32 PM
  2. Audio Programming
    By dwalters in forum Tech Board
    Replies: 0
    Last Post: 02-07-2008, 04:20 PM
  3. Problem with audio programming
    By Puzzled... in forum C Programming
    Replies: 7
    Last Post: 01-01-2008, 08:55 PM
  4. Audio Programming
    By samGwilliam in forum Windows Programming
    Replies: 1
    Last Post: 01-11-2006, 10:10 PM
  5. Audio programming... ( Perhaps Off-topic ?? )
    By KeM in forum C Programming
    Replies: 4
    Last Post: 02-16-2002, 01:15 AM

Tags for this Thread