This will help you?
http://www.devmaster.net/forums/showthread.php?t=1727
2007-01-19 00:09:48
·
answer #1
·
answered by gts 2
·
2⤊
0⤋
I'm guessing this means you need a clever combination of bitwise logical operators... but my brain is slow today, can't figure it out...
Wow, check out the page gts suggests - it's a classy solution ;)
2007-01-19 00:05:31
·
answer #2
·
answered by Anonymous
·
1⤊
0⤋
ok .. then you need to calculate the value on your brain, and write the result :D
But you can use the increment like ( A++ ) where A is the first number , and loop until the other number B equal zero
2007-01-19 00:01:14
·
answer #3
·
answered by Luay14 6
·
0⤊
3⤋
rawlyn and GTS are both right... follow the link provided by GTS.
2007-01-19 00:26:01
·
answer #4
·
answered by Wesley C 3
·
0⤊
0⤋
This software is composed of no pluses or minuses in any respect contained in this methodology (This includes ++ and --), and no * or /. It does not incorporate %, as an advantage. it works enormously very similar to the CPU binary adder circuits : examine each and each bit one by using one, upload them, in case you could carry then you definately gain this. I make no supplies you for overflow or unfavourable integers - looks to artwork yet makes it lots greater complicated. yet this might nevertheless artwork i think of for confident for any 2 constructive numbers whose sum is under 2^31. //import java.*? public type SpecialAdder{ public static void considerable(String args[]){ int num1=Integer.parseInt(args[0]);//First integer from command-line int num2=Integer.parseInt(args[a million]);//2nd integer from command-line int effect=0; boolean carry=fake;//enforce the carry as a boolean int mask=a million; for(mask=a million;(mask!=0);mask<<=a million){//bathroom... by using each and every little bit of the integer, if((num1&mask)!=0){//If Num1's contemporary bit is desperate if((num2&mask)!=0){//If Num2's contemporary bit is desperate //We could carry over, carry formerly set or no. if(carry){// a million plus a million plus carry effect|=mask;//Set to a million //carry is already actual, is left unchanged }else{// a million plus a million //Bit is already 0 carry=actual;//We could carry } }else{//Else Num2's contemporary bit isn't set //we would could carry over, depending on carry prestige if(carry){// a million plus 0 plus carry //Bit is already 0 //carry is already actual, is left unchanged }else{// a million plus 0 effect|=mask;//Set to a million //carry is already fake, left unchanged } } }else{//Else Num1's contemporary bit isn't set if((num2&mask)!=0){//If Num2's contemporary bit is desperate //we would could carry over, depending on carry prestige if(carry){// 0 plus a million plus carry //Bit is already 0 //carry is already actual, is left unchanged }else{// 0 plus a million effect|=mask;//Set to a million //carry is already fake, left unchanged } }else{//Else Num2's contemporary bit isn't set //we will not carry over, carry formerly set or no. if(carry){// 0 plus 0 plus carry effect|=mask;//Set to a million carry=fake;//We provide up carrying }else{// 0 plus 0 //Bit is already 0 //carry is already fake, left unchanged } } } } device.out.println("The sum of "+num1+" and "+num2+" is "+effect); } }
2016-10-31 12:37:21
·
answer #5
·
answered by ? 4
·
0⤊
0⤋