Click here to Skip to main content
15,894,362 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionDivision Algorithm Pin
Bagaturia david13-Nov-06 0:06
Bagaturia david13-Nov-06 0:06 
AnswerRe: Division Algorithm Pin
Sebastian Schneider13-Nov-06 2:05
Sebastian Schneider13-Nov-06 2:05 
GeneralRe: Division Algorithm Pin
Sebastian Schneider13-Nov-06 2:07
Sebastian Schneider13-Nov-06 2:07 
QuestionRe: Division Algorithm Pin
Are Jay21-Nov-06 17:39
Are Jay21-Nov-06 17:39 
AnswerRe: Division Algorithm Pin
Bagaturia david22-Nov-06 0:44
Bagaturia david22-Nov-06 0:44 
GeneralRe: Division Algorithm Pin
Are Jay22-Nov-06 3:34
Are Jay22-Nov-06 3:34 
GeneralRe: Division Algorithm Pin
Are Jay24-Nov-06 21:28
Are Jay24-Nov-06 21:28 
AnswerRe: Division Algorithm Pin
djlove24-Nov-06 7:21
djlove24-Nov-06 7:21 
Hi,

I was playing around with a BigInteger class recently and so have come across the same problem.

The fastest way I could think of is below, if you say x / y = z (with remainder = r).

1. Find the leading 64 bits of your big number (x)
2. Find the leading 32 bits of your divisor (y).
3. Divide (1) by (2) to give you the leading 32 bits of z.
4. Multiply (3) by y and take this number from x

Continually applying steps 1-4 reduces the size of x until you are within +/- 1 of the correct value of z.

This is fast because all operations are O(n) or less if you code them properly!

Hope this is of some use & good luck!

Russ
AnswerRe: Division Algorithm Pin
Dan21786-Dec-06 19:01
Dan21786-Dec-06 19:01 
Questionhelp me with binary search Pin
MaSTaMaRViN12-Nov-06 23:09
MaSTaMaRViN12-Nov-06 23:09 
AnswerRe: help me with binary search Pin
Tim Craig13-Nov-06 19:50
Tim Craig13-Nov-06 19:50 
AnswerRe: help me with binary search Pin
David Crow5-Dec-06 5:36
David Crow5-Dec-06 5:36 
GeneralRe: help me with binary search Pin
ricecake6-Dec-06 3:53
ricecake6-Dec-06 3:53 
GeneralWell and truly sorted Pin
intrepid_is12-Nov-06 5:58
intrepid_is12-Nov-06 5:58 
GeneralRe: Well and truly sorted Pin
peterchen12-Nov-06 8:14
peterchen12-Nov-06 8:14 
GeneralRe: Well and truly sorted Pin
intrepid_is12-Nov-06 11:43
intrepid_is12-Nov-06 11:43 
QuestionRe: Well and truly sorted Pin
David Crow5-Dec-06 5:37
David Crow5-Dec-06 5:37 
AnswerRe: Well and truly sorted Pin
peterchen5-Dec-06 17:01
peterchen5-Dec-06 17:01 
QuestionSetFileTime Pin
toeh11-Nov-06 23:09
toeh11-Nov-06 23:09 
AnswerRe: SetFileTime Pin
coolestCoder12-Nov-06 0:16
coolestCoder12-Nov-06 0:16 
Questionvb6 algorithm Pin
irwansmadaxip110-Nov-06 11:57
irwansmadaxip110-Nov-06 11:57 
AnswerRe: vb6 algorithm Pin
Tim Craig10-Nov-06 17:16
Tim Craig10-Nov-06 17:16 
GeneralRe: vb6 algorithm Pin
Paul Conrad14-Nov-06 3:57
professionalPaul Conrad14-Nov-06 3:57 
GeneralRe: vb6 algorithm Pin
Tim Craig14-Nov-06 19:00
Tim Craig14-Nov-06 19:00 
GeneralRe: vb6 algorithm Pin
ChandraRam15-Nov-06 0:39
ChandraRam15-Nov-06 0:39 

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.