Click here to Skip to main content
16,005,734 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionPlease help Pin
A*****5-May-07 20:30
A*****5-May-07 20:30 
AnswerRe: Please help Pin
cp98765-May-07 20:47
cp98765-May-07 20:47 
AnswerRe: Please help Pin
Nathan Addy8-May-07 15:03
Nathan Addy8-May-07 15:03 
GeneralThanks Nathan Addy Pin
A*****9-May-07 15:49
A*****9-May-07 15:49 
QuestionMutliplying a very long number Pin
MoustafaS5-May-07 10:53
MoustafaS5-May-07 10:53 
AnswerRe: Mutliplying a very long number Pin
Luc Pattyn5-May-07 12:20
sitebuilderLuc Pattyn5-May-07 12:20 
GeneralRe: Mutliplying a very long number Pin
Arun.Immanuel5-May-07 20:51
Arun.Immanuel5-May-07 20:51 
GeneralRe: Mutliplying a very long number Pin
cp98765-May-07 22:30
cp98765-May-07 22:30 
I don't know how Luc did it, but using any large integer library will allow you to do it. Some languages support large integers, e.g. in Python (free), typing pow(2,1000) gives:
<br />
>>> pow(2,1000)<br />
1071508607186267320948425049060001810561404811705533607443750388370351051124936122493198378815695858<br />
1275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954<br />
1821530464749835819412673987675591655439460770629145711964776865421676604298316526243868372056680693<br />
76L<br />


I know that mathematica also supports large integers.

To do it in say c++, you need to write code, or use a large integer library - type large integer into the search box at the top of the page.

If you are asking how it is done, simply by using long multiplication / division. If the native int representation is 32 bits, then to represent a 1001 bit number needs 32 ints. You can write routines to do standard +,=,* and / operations on these numbers, it is much the same as in base 10 - you need to worry about carrying and borrowing. It is not that hard - I did it some years ago when I wrote some crypto routines (one of the major uses for large integer libraries these days), but libraries are readily available these days. Long division is the tricky one - I confess to resorting to Donald Knuth's book to get my algorithm right.

To work out 2^1000 is simply a number with 1 followed by 1000 '0's as Luc noted, the decimal representation is probably worked out using long division.






Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

GeneralRe: Mutliplying a very long number Pin
Arun.Immanuel5-May-07 22:36
Arun.Immanuel5-May-07 22:36 
GeneralRe: Mutliplying a very long number Pin
Luc Pattyn5-May-07 23:42
sitebuilderLuc Pattyn5-May-07 23:42 
GeneralRe: Mutliplying a very long number Pin
MoustafaS6-May-07 4:23
MoustafaS6-May-07 4:23 
AnswerRe: Mutliplying a very long number Pin
Bassam Abdul-Baki8-May-07 15:48
professionalBassam Abdul-Baki8-May-07 15:48 
QuestionRotation Matrix Pin
wajih.boukaram4-May-07 12:23
wajih.boukaram4-May-07 12:23 
AnswerRe: Rotation Matrix Pin
cp98765-May-07 2:56
cp98765-May-07 2:56 
AnswerRe: Rotation Matrix Pin
Paul Conrad5-May-07 5:22
professionalPaul Conrad5-May-07 5:22 
AnswerRe: Rotation Matrix Pin
spin vector16-May-07 2:36
spin vector16-May-07 2:36 
GeneralRe: Rotation Matrix Pin
cp987616-May-07 3:41
cp987616-May-07 3:41 
AnswerRe: Rotation Matrix Pin
Frank Kerrigan21-May-07 23:40
Frank Kerrigan21-May-07 23:40 
QuestionMaths Pin
Jbones30-Apr-07 18:54
Jbones30-Apr-07 18:54 
AnswerRe: Maths Pin
cp987630-Apr-07 19:16
cp987630-Apr-07 19:16 
AnswerRe: Maths Pin
CPallini1-May-07 7:31
mveCPallini1-May-07 7:31 
GeneralRe: Maths Pin
Frank Kerrigan2-May-07 5:35
Frank Kerrigan2-May-07 5:35 
GeneralRe: Maths Pin
CPallini2-May-07 5:41
mveCPallini2-May-07 5:41 
GeneralRe: Maths Pin
Frank Kerrigan2-May-07 5:52
Frank Kerrigan2-May-07 5:52 
GeneralRe: Maths Pin
Paul Conrad2-May-07 11:05
professionalPaul Conrad2-May-07 11:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.