CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #2
    Join Date
    Oct 2006
    Posts
    616

    Re: Are Binary Operators Used Alot in Modern Programming

    I think you are confusing binary operators with Bitwise operators.
    Binary operators are operators which take 2 arguments, usually left and right arguments, for example: =, <<, >>, %, ...

    Bitwise operators are operators which operate on the bits of a variabe. Ofcourse, some bitwise operators can also be binary operators.

    For example, operator &:
    Consider the binary representation of a short, it has 8 bits. For instance, the number 7 will be represented as 00000111.
    Code:
    short res = 7 & 1;
    So you may ask what does the meaning of the code above. Well, the bitwise operator &, operates as an AND operation on each of the bits. The result bit will be 1 if and only if the 2 arguments matching bit is also 1:
    Code:
    7 (Decimal) = 00000111 (Binary)
                     &
    1 (Decimal) = 00000001 (Binary)
                          ------------
    res =         00000001 (Binary) = 1 (Decimal)
    You can also check this link for more references. About your question, if they are used alot - well it depends on the application and the requirements, but they can speed up calculations plenty of times and I have seen these operators put to commercial use plenty of times.
    Last edited by Zachm; March 31st, 2007 at 03:54 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured