unir 2 int sin sumar, solo juntar

saludos como dice el titulo busco la forma de unir 2 int no en suma si no unir ambos uno después del otro busco a algo así, que en un tercer int se pueda juntar, el resultado debe ser 132.

int A=1;
int B=32;

int JUNTAR;

void setup() {

Serial.begin(9600);

//Aqui puede ir la operacion que los juntara 
//y lo dara en la 3er int JUNTAR 




Serial.println(JUNTAR); // junto debe ser así 132 en un solo int
}

void loop() {

}

JUNTAR = (A*100)+B

Saludos.

Convertir a string y concatenar es otra solución

Se pasan a strings, se concatenan y se devuelve como int, por ejemplo:

// Concatenar dos enteros, retorna entero.
int concatInt(int a,int b){
  String s = String(a) + String(b);
  return s.toInt();
}

void setup() {
  Serial.begin(9600);
  Serial.println( concatInt(1,32) );

}

void loop() {
  // put your main code here, to run repeatedly:

}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.