multiplying a bignumber

altafahmed2k4's Avatar, Join Date: Aug 2006
Go4Expert Member
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
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Integers can't hold numbers big like 2^16.
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Quote:
Integers can't hold numbers big like 2^16.


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.

Last edited by DaWei; 29Dec2006 at 19:51..
0
altafahmed2k4's Avatar, Join Date: Aug 2006
Go4Expert Member
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
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
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.