Big number in C++

后端 未结 9 1538
暖寄归人
暖寄归人 2020-12-16 19:13

I am trying to place a big number in a C++ variable. The number is 600851475143

I tried unsigned long long int but got an error saying it the constant was too big.

9条回答
  •  自闭症患者
    2020-12-16 20:04

    In a more general case when you cannot fit your number in a long long, and can live with the GNU LGPL license (http://www.gnu.org/copyleft/lesser.html), I would suggest trying the GNU Multiprecision Library (http://gmplib.org/).

    It is extremely fast, written in C and comes with a very cool C++-wrapper-library.

提交回复
热议问题