Hi!
I wonder how can I put two or more number together, like if I have:
int t = 1;
int p = 2;
int h;
h = t + p
Than "h" will be equals 3, but I will it to be 12. How can I do that?
Thanks!
-HansDia
Hi!
I wonder how can I put two or more number together, like if I have:
int t = 1;
int p = 2;
int h;
h = t + p
Than "h" will be equals 3, but I will it to be 12. How can I do that?
Thanks!
-HansDia
I wonder how can I put two or more number together,
It would be interesting to know where the 2 numbers come from and why you want to put them together. Once "put together" what are you going to do with the result ?
convert to strings, concatenate the strings, convert to integer?
What do you want for 0+0? 0 or 00 ?
Are you parsing a serial stream? perhaps you want parseInt()?
HansDia:
int t = 1;
int p = 2;
int h;
h = t + p
Than "h" will be equals 3, but I will it to be 12. How can I do that?
This seems to me a good example where meaningful variable names would help. For example with
int tensDigit = 1;
int unitsDigit = 2;
int combinedValue;
I doubt if you would have attempted
combinedValue = tensDigit + unitsDigit;
...R
Yes I want 1+1=11, not 2
I just thought that was a solution to make passcode with a keypad ![]()
I just thought that was a solution to make passcode with a keypad
It is as long as the variables that you are dealing with are actually numbers and not ASCII representations of numbers. Have you got any actual code that uses a keypad to input numbers ?