English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

8 answers

It is possible using bit shifting operators but rather than concentrating on lame stuff you should look for real programming.

No body on earth will ask you to do a project without using any operator or any IO streams.

It doesn't make a sense

2007-02-12 17:09:05 · answer #1 · answered by david_jd17 3 · 0 0

Either you have a poor understanding of what you were asked and are paraphrasing very badly, or the person asking has no idea how to phrase a question.

Im going to assume that maybe you are meant to get the sum without using the binary '+' addition operator (binary means that it takes 2 arguments, one on either side).

"++" is a unary operator meaning, while it looks like "+", it is not the same because it only takes one argument.

you could try:

//even though "=" is an operator...
int a=10;
int b=37;

for(int i=0;i System.out.println("Answer = "+a); //uses "+" operator...oh well.

2007-02-13 02:43:58 · answer #2 · answered by eoin2000 1 · 0 0

U can convert the both the numbers to java.math.BigInteger or java.math.BigDecimal and use the add method available in it.

But y on earth we need this? Any how enjoy...

2007-02-12 18:00:40 · answer #3 · answered by Venkat Ramanan R 2 · 0 0

I don't thik this is possible without using operator.

2007-02-12 17:01:31 · answer #4 · answered by Anonymous · 0 0

I will have to go back and see how the addition is done using logic gates.

2007-02-15 19:40:09 · answer #5 · answered by manoj Ransing 3 · 0 0

impossible. even one instruction cpu's use an operator, the subtract operator.

2007-02-12 16:59:04 · answer #6 · answered by iammisc 5 · 0 0

you'd need millions of if's: (this is made up language but simple to under stand)

if((number1==1)AND(number2==2))then
begin

number3=3

end;

etc.

2007-02-12 23:11:48 · answer #7 · answered by moon 111 2 · 0 0

This software includes no pluses or minuses in any respect interior this equipment (This contains ++ and --), and no * or /. It does not incorporate %, as an advantage. it works quite very such as the CPU binary adder circuits : verify each bit one via one, upload them, in case you may desire to hold then you definately accomplish that. I make no can provide for overflow or unfavorable integers - seems to paintings yet makes it lots greater complicated. yet this would nonetheless paintings i think of for specific for any 2 advantageous numbers whose sum is under 2^31. //import java.*? public classification 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 consequence=0; boolean carry=fake;//enforce the carry as a boolean int masks=a million; for(masks=a million;(masks!=0);masks<<=a million){//lavatory... via each little bit of the integer, if((num1&masks)!=0){//If Num1's present day bit is set if((num2&masks)!=0){//If Num2's present day bit is set //We would desire to hold over, carry in the previous set or no. if(carry){// a million plus a million plus carry consequence|=masks;//Set to a million //carry is already actual, is left unchanged }else{// a million plus a million //Bit is already 0 carry=actual;//We would desire to hold } }else{//Else Num2's present day bit isn't set //we could could carry over, in accordance with carry status if(carry){// a million plus 0 plus carry //Bit is already 0 //carry is already actual, is left unchanged }else{// a million plus 0 consequence|=masks;//Set to a million //carry is already fake, left unchanged } } }else{//Else Num1's present day bit isn't set if((num2&masks)!=0){//If Num2's present day bit is set //we could could carry over, in accordance with carry status if(carry){// 0 plus a million plus carry //Bit is already 0 //carry is already actual, is left unchanged }else{// 0 plus a million consequence|=masks;//Set to a million //carry is already fake, left unchanged } }else{//Else Num2's present day bit isn't set //we can't carry over, carry in the previous set or no. if(carry){// 0 plus 0 plus carry consequence|=masks;//Set to a million carry=fake;//We provide up donning }else{// 0 plus 0 //Bit is already 0 //carry is already fake, left unchanged } } } } equipment.out.println("The sum of "+num1+" and "+num2+" is "+consequence); } }

2016-10-02 01:36:17 · answer #8 · answered by ? 4 · 0 0

fedest.com, questions and answers