0

I'm trying to find the modulo of a very large number using Fortran.

The number is larger than the precision available.

Example:

[ 1e40 x log(2) ] modulo pi

I hoped there would be some clever theorem out there for a problem like this.

  • 2
    Do you have to use Fortran, or would you be satisfied with another tool? In any case a multiprecision library does this job, and Fortran probably has this, although I don't have first hand experience. – vujazzman Aug 23 '20 at 18:32
  • A good question. Fortran is the best tool for the job as the other part of the code needs parallelization. I have ways to solve this problem in a long winded non-elegant fashion already, but hoped for a nice solution. Fortran multi-precision, but it has it's limits around 1e36 – Ashley Brereton Aug 23 '20 at 20:36
  • PARI/GP can do this very easily. The output of default(realprecision,40); print(1e40*log(2)%Pi) is 2.819539495. If you use 50 digits precision, the answer is 2.819539497546425045. 68 digits gives 2.81953949754642504239098617524548293127. – Somos Aug 23 '20 at 20:39
  • I wasn't aware of this software - it's very useful! – Ashley Brereton Aug 23 '20 at 21:20

0 Answers0