How can i put together two int value in a new int?

How can i put together two int value in a new int?

int one = 1;
int two = 2;
int twelve;

void setup() {
Serial.begin (9600);
twelve = twelve + one;
twelve = twelve & two; //here i want the int "twelve" get the value 12 but i can't find the way

Serial.println (twelve);
}

void loop() {


}

Did you sleep through math class all the way through school?

twelve = 10 * one + two;

twelve = 10 * one + two;

I can't understand the logic behind but thank u very much.

(deleted)

Did you sleep through math class all the way through school?

Huh? What is a "math class"?

Does anyone know a good const variable name for value 10?

GrOnThOs:
Does anyone know a good const variable name for value 10?

const int ten = 10;

GrOnThOs:
Does anyone know a good const variable name for value 10?

Slept through English class also :slight_smile:

...R

Robin2:
Slept through English class also :slight_smile:

...R

Bet he woke up for Sex Ed.

I was never present on an English classroom.
But this seems to me more like as personal attack rather than answer to a programming question.

(deleted)

But this seems to me more like as personal attack rather than answer to a programming question.

We are trying to make light of the fact that someone who doesn't even understand the decimal number system is attempting to program a computer.

Be warned: you have an extremely long, dusty road to travel, on foot.

GrOnThOs:
Does anyone know a good const variable name for value 10?

How about "tenToTheFirstPower" ?

We are talking about computers aren't we? So I'm going for Two.

Steve

Maybe we could get GolamMustafa to drop by and give a real complicated explanation of how this works involving 8-bit adders and registers and primitive assembly commands from long extinct processors

To get 12 (a decimal value) from the discrete positional factors 1 (Ten Positional Factor) and 2 (Unit Positional factor), the following approach is being presented which is still practiced in hard computer science classes!

12 = Value
Value = 1x101 + 2x100

===> Value = Ten Positional Factor (TPF) x Ten Positional Weight (TPW) + Unit Positional Factor (UPF) x Unit Positional Weight (UPW)

===> Value = TPF x TPW + UPF x UPW
 while (UPF != 0)
{
   IPR1 = IPR1 + UPW   //IPR1 = 0x02
}

while (TPF !=0)
{
   IPR2 = IPR2 + TPW    //IPR2 = 0x0A
}

Value = IPR1 + IPR2      //Value = 0x0C

Serial.print(Value, DEC);   //12

8085 Assembly Codes:

 MVI   A, 00H            ; IPR1 = A = 00H
      MVI   C, 02H            ; UPF   = 02H
L1: ADD   A, 01H            ; UPW  = 01H
      DEC   C
      JNZ    L1                  ; IPR1 = A

      MOV   B, A                ; IPR1 = B = 02H
      MOV   A, 00H            ; IPR2 = A = 00H
      MOV   C, 01H            ; TPF   = 01H
L2: ADD    A, 0AH           ;  TPW = 10 = 0AH
      DEC     C
      JNZ      L2

L3:  ADD    A, B              ; A = 0CH = 00001100

L4: ;converting Binary to Decimal (BCD) using Horner Rule
for (n = 7; n >=0; x--)
{
IPBCD x 2 + bn ------> IPBCD //IPBCD = 12
DAA
}

Delta_G:
It may just be that the OP is expecting it to be harder than that. You know, overthinking it.

Maybe we could get GolamMustafa to drop by and give a real complicated explanation of how this works involving 8-bit adders and registers and primitive assembly commands from long extinct processors

With flowcharts...

GrOnThOs:
Does anyone know a good const variable name for value 10?

[C++ Programming Style Guidelines](C++ Programming Style Guidelines Conventions)

+1 Karma for GolamMustafa for the good sense of humor and hard work :slight_smile:

GolamMostafa:
8085 Assembly Codes:
MVI A, 00H ; IPR1 = A = 00H
MVI C, 02H ; UPF = 02H
L1: ADD A, 01H ; UPW = 01H
DEC C
JNZ L1 ; IPR1 = A

MOV B, A ; IPR1 = B = 02H
MOV A, 00H ; IPR2 = A = 00H
MOV C, 01H ; TPF = 01H
L2: ADD A, 0AH ; TPW = 10 = 0AH
DEC C
JNZ L2

L3: ADD A, B ; A = 0CH = 00001100

8085 assembly!!
brain memories of youth.....back in1981

Thank you so much to you all!