Double precision in C++ (or pow(2, 1000))

前端 未结 7 638
情书的邮戳
情书的邮戳 2021-01-14 19:38

I\'m working on Project Euler to brush up on my C++ coding skills in preparation for the programming challenge(s) we\'ll be having this next semester (since they don\'t let

7条回答
  •  庸人自扰
    2021-01-14 20:06

    C/C++ operates on fundamental data types. You are using a double which has only 64 bits to store a 1000 bit number. double uses 51 bit for the significant digits and 11 bit for the magnitude.

    The only solution for you is to either use a library like bignum mentioned elsewhere or to roll out your own.

提交回复
热议问题