Facebook Page
Twitter
RSS
+ Reply to Thread
Results 1 to 5 of 5
  1. MHB Craftsman

    Status
    Offline
    Join Date
    Jan 2014
    Posts
    236
    Thanks
    133 times
    Thanked
    41 times
    #1
    "Assume integer variable A holds 60 and variable B holds 13 then:


    A&B will give 12"

    Why is this?

  2. MHB Master
    MHB Site Helper
    MHB Math Helper
    evinda's Avatar
    Status
    Online
    Join Date
    Apr 2013
    Posts
    3,240
    Thanks
    3,196 times
    Thanked
    971 times
    Awards
    MHB Model User Award (2016)  

MHB Model User Award (2014)
    #2
    Quote Originally Posted by tmt View Post
    "Assume integer variable A holds 60 and variable B holds 13 then:


    A&B will give 12"

    Why is this?
    Write the binary represetation of $A$ and $B$ and then add them.
    For example, the binary representation of $A$ is $0011 1100$.

  3. MHB Craftsman

    Status
    Offline
    Join Date
    Jan 2014
    Posts
    236
    Thanks
    133 times
    Thanked
    41 times
    #3 Thread Author
    Quote Originally Posted by evinda View Post
    Write the binary represetation of $A$ and $B$ and then add them.
    For example, the binary representation of $A$ is $0011 1100$.
    I get 01001001 how is this 12?

  4. MHB Master
    MHB Site Helper
    MHB Math Helper
    evinda's Avatar
    Status
    Online
    Join Date
    Apr 2013
    Posts
    3,240
    Thanks
    3,196 times
    Thanked
    971 times
    Awards
    MHB Model User Award (2016)  

MHB Model User Award (2014)
    #4
    Quote Originally Posted by tmt View Post
    I get 01001001 how is this 12?
    You have to use this truth table for &:

    $$\begin{bmatrix}
    p & q & p \& q \\
    0 & 0 & 0\\
    0 & 1 & 0 \\
    1 & 1 & 1\\
    1 & 0 &0
    \end{bmatrix}$$

    Then, the result will be $0000 1100$.

  5. MHB Craftsman
    MHB Math Helper

    Status
    Offline
    Join Date
    Jan 2013
    Posts
    227
    Thanks
    20 times
    Thanked
    339 times
    Thank/Post
    1.493
    Awards
    Graduate POTW Award (Jul-Dec 2013)
    #5
    In C, Java and other languages, & is the bitwise and of the integer operands. So for example, 6 & 4 is 110 & 100 = 100 = 4. Similarly | is the bitwise or operator. So 6 | 4 = 110 | 100 = 110 = 6. Similarly ^ is the bitwise exclusive or operator. So 6 ^ 4 = 010 = 2.

Similar Threads

  1. Arithmetic sequence
    By Albert in forum Challenge Questions and Puzzles
    Replies: 2
    Last Post: December 8th, 2013, 06:16
  2. Arithmetic Geometry
    By mathbalarka in forum Linear and Abstract Algebra
    Replies: 13
    Last Post: November 18th, 2013, 09:21
  3. Arithmetic sequence
    By wishmaster in forum Pre-Calculus
    Replies: 22
    Last Post: November 9th, 2013, 05:47
  4. Modular Arithmetic
    By matqkks in forum Number Theory
    Replies: 4
    Last Post: September 23rd, 2013, 10:58
  5. arithmetic seq.
    By gotah in forum Pre-Algebra and Algebra
    Replies: 1
    Last Post: March 23rd, 2012, 13:05

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Math Help Boards