Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   multiplying a bignumber (http://www.go4expert.com/forums/multiplying-a-bignumber-t2379/)

altafahmed2k4 29Dec2006 11:42

multiplying a bignumber
 
Task is
>>I should create a way to get a bignumber ie >2^16 for Turboc using as a string
and store it in a binary format (integer).
>>The number should be reusable

pradeep 29Dec2006 12:06

Re: multiplying a bignumber
 
Integers can't hold numbers big like 2^16.

DaWei 29Dec2006 19:48

Re: multiplying a bignumber
 
Quote:

Integers can't hold numbers big like 2^16.
http://www.daweidesigns.com/images/eyebrow.gif

Depends on how your integer is defined. Mine are 32-bit (with a provision for an int64). 2^16 is a mere drop in the bucket. If your implementation can only deal with 16-bit integers, then you have to take on the task of chaining them together, yourself. You do it every day when you operate on decimal numbers using pencil and paper.

altafahmed2k4 30Dec2006 01:11

Re: multiplying a bignumber
 
thank u all i know about 2^16 but

one thing
>>i have to enter a big number as a string and that number should be accepted as any normal number and it should be stored as array for eg
if number is 65536

then a[0]=0
a[1]=1

now i think i have made it clear can any one help me

DaWei 30Dec2006 04:07

Re: multiplying a bignumber
 
If you're using one array element for each binary digit, then you need an array for each operand. You then work with the individual elements of those arrays in the same way that the ALU in your uP works with individual bits.

To begin with, you're going to have to know how to implement a full-adder. It's just an exclusive-or with carry. Once you can add, you can subtract (think two's complement). Once you can add and subtract, you can multiply and divide.

I suspect they are teaching you how a uP works, so you might want to begin by studying that, binary arithmetic, etc.


All times are GMT +5.5. The time now is 06:43.