Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dividing 1 by a huge integer [closed]

I have to divide 1 by a number X of more than 4000 digits that I have stored in a string and obviously this is going to return a floating point number. I'm looking for algorithms to perform this division efficiently but I could not find anything that convinces me.

As a side note, I would like to implement the algorithm on my own without using a third-party library.

Anyone have any idea?

Thanks!

EDIT: The reason why I do not want to use a third-party library it's that I want to do this operation using openCL but without losing too much accuracy in the process. Therefore using one of those libraries is actually not possible in this case.

like image 422
Ignacio A. Rivas Avatar asked Jul 20 '11 15:07

Ignacio A. Rivas


1 Answers

You are describing a special case of division, known as inverting a number. Here's a paper which gives a description of Picarte's Iteration method of inverting a large integer: http://www.dcc.uchile.cl/~cgutierr/ftp/picarte.pdf

like image 137
Mark Ransom Avatar answered Sep 20 '22 05:09

Mark Ransom