This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

subtraction of 2 ascii arrays

Hey i wants to get idea for how to subtact two arrays of ascii chracters of amount....

e.g.

unsigned char ary1[3],ary2[3],ary[3];

ary1[1]=0x32; //0x32 is ascii code for 2
ary1[2]=0x31; //same 0x31 is ascii code of 1
ary1[3]=0x34;

ary2[1]=0x35;
ary2[2]=0x32;
ary2[3]=0x35;

Please give me idea.....
I am facing problem for carry forwarding....

Parents
  • Binary, octal, decimal, hexadecimal, ...

    Just different way of presenting a number.

    But the binary number 10001 is still the same number as the octal number 21, the decimal number 17 or the hexadecimal number 11.

    And next thing - having each array entry store ASCII '2' or just 2 doesn't really change the way you perform the subtract, since '0' + 2 = '2'. Having an arbitrary (but constant) offset added to all digits _only_ requires you to make sure that the variables you use are big enough to store the numbers. When you make the offsets large enough, you will no longer be able to work with 8-bit variables. But an ASCII digit obviously do fit in an 8-bit variable.

Reply
  • Binary, octal, decimal, hexadecimal, ...

    Just different way of presenting a number.

    But the binary number 10001 is still the same number as the octal number 21, the decimal number 17 or the hexadecimal number 11.

    And next thing - having each array entry store ASCII '2' or just 2 doesn't really change the way you perform the subtract, since '0' + 2 = '2'. Having an arbitrary (but constant) offset added to all digits _only_ requires you to make sure that the variables you use are big enough to store the numbers. When you make the offsets large enough, you will no longer be able to work with 8-bit variables. But an ASCII digit obviously do fit in an 8-bit variable.

Children
No data