How do I avoid scientific notation for large numbers?

后端 未结 8 1166
Happy的楠姐
Happy的楠姐 2020-12-15 05:04

I am doing 2^1000 and I am getting this:

1.07151e+301

Is there any way to actually turn this into a proper number without the e+301, or at least can anyone s

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 05:34

    There is a practical limit to how large a number that can be directly manipulated in machine registers can be. if you are using double precision floats there are a total of 64 bits, some of which are devoted to the mantissa, some to the exponent, and 1 to the sign bit.

    2^1000 needs a 1001 bit integer to be represented without losing precision. In order to work with numbers like that you will need to use a library that has big number support, such as GNU MP.

提交回复
热议问题