Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How can I set a bit to 0 ? (Add Two Numbers Using Only Bitwise Operators)

by eyepopslikeamosquito (Archbishop)
on May 28, 2022 at 10:18 UTC ( [id://11144245]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Perl program to add two numbers using only bitwise operators
    # See https://stackoverflow.com/questions/4068033/add-two-integers-usi
    +ng-only-bitwise-operators
    ...
       $sum0 == $sum2 or die "oops 2";
       $sum1 == $sum2 or die "oops 3";
    }
    
  2. or download this
    0 + 1 = 1 (1 1)
    1 + -1 = 0 (0 0)
    ...
    123456789 + 1 = 123456790 (123456790 123456790)
    2147483647 + 1 = 2147483648 (2147483648 2147483648)
    -2147483648 + 1 = -2147483647 (-2147483647 -2147483647)
    
  3. or download this
    // C++ Program to add two numbers without using arithmetic operator.
    // bitadd.cpp
    ...
    
       return 0; 
    }
    
  4. or download this
    sizeof my int = 8
    0 + 1 = 1 (1)
    ...
    123456789 + 1 = 123456790 (123456790)
    2147483647 + 1 = 2147483648 (2147483648)
    -2147483648 + 1 = -2147483647 (-2147483647)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11144245]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found