Click here to Skip to main content
15,888,521 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionDuplicateHandle Pin
tom groezer8-May-07 5:56
tom groezer8-May-07 5:56 
AnswerRe: DuplicateHandle Pin
Stephen Hewitt8-May-07 14:16
Stephen Hewitt8-May-07 14:16 
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 
Hi,

2^1000 has more than 300 decimal digits, obviously it wont fit in an int or a long.

2^1000 = 10,715,086,071,862,673,209,484,250,490,600,018,105,614,048,117,
055,336,074,437,503,883,703,510,511,249,361,224,931,983,788,
156,958,581,275,946,729,175,531,468,251,871,452,856,923,140,
435,984,577,574,698,574,803,934,567,774,824,230,985,421,074,
605,062,371,141,877,954,182,153,046,474,983,581,941,267,398,
767,559,165,543,946,077,062,914,571,196,477,686,542,167,660,
429,831,652,624,386,837,205,668,069,376
(302 digits)


there are basically three ways to get all the digits:

1.
use very clever code, based on mathematics, to calculate one or a few digits at a time,
without ever holding them all. Hint: the last digit can easily be predicted, the powers of
two end on 2/4/8/6/2/4/8/6/...

2.
use a library that can handle "big integers"; there are some on CP, and many more on Google.
Only a very small part of such a lib is actually needed here, since 2^1000 simply gets
represented as a 1 followed by a thousand zeroes in binary. So the one thing that remains
to be done is the ToString() of that...

3.
cheat and go to http://www.newdream.net/~sage/old/numbers/pow2.htm[^]

Smile | :)


Luc Pattyn

[My Articles]

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 
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 

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.