Concatenate
edwgeo
Junior Member
I need conacatenate two varaibles for example:
a=5
b=0
c=a + b // resul=50
what is the function for to realize this operation.
I do not want that the result is c=5
a=5
b=0
c=a + b // resul=50
what is the function for to realize this operation.
I do not want that the result is c=5
Comments
-
If a always represents the 10 position and b always represents the 1 position then you can just do the math:
c = (a*10) + bedwgeo wrote:I need conacatenate two varaibles for example:
a=5
b=0
c=a + b // resul=50
what is the function for to realize this operation.
I do not want that the result is c=5 -
edwgeo wrote:I need conacatenate two varaibles for example:
a=5
b=0
c=a + b // resul=50
what is the function for to realize this operation.
I do not want that the result is c=5
Another way would be to convert to a Char and back to an integer...a = 5 b = 0 c = Atoi("Itoa(a), Itoa(b)") // c = 50 -
concatenate to a char and then ATOI() back like dchristo says works best, can't go wrong
-
Two Wrongs Don't Make a Right but Three Rights Do Make a Left
yuri my Dutch friend, your statement is a real head scratcher. It’s kind of like telling someone that is traveling north and wants to head west that the best way is to take 3 right turns instead of 1 left.
It’s certainly one way to do it and it’s good to know for future reference but I don’t see how you can go wrong with c = (a*10) + b. Math is your friend. 
…tfel egats gnitixEyuri wrote:concatenate to a char and then ATOI() back like dchristo says works best, can't go wrong
Edit: Exited wrong direction -
Joe Hebert wrote:?tfel egats gnitixE
Edit: Exited wrong direction
Too funny! Good point though Joe! -
Joe,
I think Yuri is referring to the possibility that a is not always going to be the tens digit. If for some reason a=11 and b=13, the best way (in my mind) to end up with 1113 is to do the ATOI("ITOA(a),ITOA(b)") method. You could use math and conditional statements to determine how many digits are in b and then multiply a accordingly, but the conversion method is shorter.
If a is ALWAYS a single digit 10s place, and b is ALWAYS a single digit 1s place, then I would agree that the best method is the arithmetic method.
Jeff -
Excellent Point, Jeff!
Actually it doesn’t matter how many digits a is.Spire_Jeff wrote:If a is ALWAYS a single digit 10s place, and b is ALWAYS a single digit 1s place, then I would agree that the best method is the arithmetic method.
If a=12345 and b=9 then c=(12345*10)+9=123459 and the math works.
But, and that’s a big butt, if b > 9 then yes indeed I’m entirely wrong (damn you Jeff and yuri!
) and I didn’t think it all the way through.
Can somebody please get me a towel so I can wipe the egg off me face?
Screw the math.
Backpedaling stage right… -
Joe Hebert wrote:Actually it doesn?t matter how many digits a is.
If a=12345 and b=9 then c=(12345*10)+9=123459 and the math works.
But, and that?s a big butt, if b > 9 then yes indeed I?m entirely wrong (damn you Jeff and yuri!
) and I didn?t think it all the way through.
Can somebody please get me a towel so I can wipe the egg off me face?
Screw the math.
Backpedaling stage right?
hahahaha
i think the trouble started with me not formatting my sentence correctly
i've learned from my own faults that creating something that works for one cause can create errors when using it for another... always create something that works whichever way you go (norht, east, south, west
)
I'd rather take 3 right and get to my location, than taking one left and fall into the ocean (or something, that's some Japanese stuff there!
)
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums