tags:

views:

20

answers:

1

Hello , i was wondering if there was anyway of combining two characters to form one character. For instance, i have the character 6 and 7 , i want to combine them and make the result 67 that is saved in a register, is there any solution to this problem ?

//Thx in advance

A: 

Do you mean you want to store the numerical value of a string of digit characters?

If so, you can take each character's ASCII value (perform the necessary checking to make sure it's in the appropriate range), subtract the value of '0' from it, multiply it by 10 to the power of its position (numbered in reverse order, starting from 0) and then add it to a total value.

For example:

"67" -> 54, 55 -> (54-48)*10^1, (55-48)*10^0 -> (6*10)+(7*1) = 67
Moonshield
Thank you, got it to work :)
Krewie
@Krewie No problem.
Moonshield