We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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....
No, you will not be handed a ready-done solution on a plate - you need to think for yourself!
Have you actually thought about the suggestions given so far?
By the way - don't write:
ary1[1]=0x32; //0x32 is ascii code for 2
when it's easier to read (and no need for the comment).
ary1[1]='2';
Yes... i thought for ascii conversion to hex but then problem is that how to subtract arrays of hex numbers...
Thats y i want 2 know about direct subtraction rather then char wise subtraction and then forwarding carry to next..
"but then problem is that how to subtract arrays of hex numbers."
Eh???
"direct subtraction rather then char wise subtraction"
"forwarding carry to next."
How many times does it have to be said: think about how you would do this manually with pencil and paper.
If you don't understand the basics of how to do it yourself, how can you hope to implement it in a program??
online.edfac.unimelb.edu.au/.../algorith.htm
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.