You have two alternatives:
1) Use BCD. The Intel 80x86 series can work with BCD.
2) Use multi-word math. The Intel 80x86 series can also work with multiple words.
Personally I recommend the multi-word solution.
You can find some multi-word maths stuff on this forum in threads dukely started, asking about 64-bit maths. "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
Come now. N! is a LARGE number. So how do you handle large numbers which would overflow your processor's normal word, which is 32-bit? You use BCD or multi-word maths. Multi-word maths is prolly your best bet. It's up to YOU to wonder how your going to implement N!: N! is simply:
product X=2 to N of X
which you can implement in a loop. Doing the multiplication, however, requires knowledge of how to implement multiplication using several words.
The relevant threads are:
thread272-396253 threads discuss some stuff about multiplication.
Also, choose: multi-word maths or BCD?
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
Now the requirement changes to displaying up to 500 digits...the multi-word maths would not work. Someone told me using array to store single digit in each element..but i am not sure how to do it
No, multi-word maths will still work. The only problem is that you have a LOT of work to do to implement it. In fact, using unpacked BCD (which is what you suggested, storing a single digit in one byte is unpacked BCD...) may be more difficult than using multi-word maths. The problem you have is writing a routine to convert a multi-word binary to a displayable decimal number, which is why you may want to use unpacked BCD. However once you've got the conversion routine licked, I suggest you use multi-word binary representation, especially since unpacked BCD can be s--- slow. "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.