写了个密码排列组合有关的程序.要计算所有的可能,结果__int64都不够用了.
有没有比较全面的__int128实现方案:1.支持基本的运算.并支持和其它类型(如DWORD64 DWORD)等数据进行运算.2.支持该类型数据的格式化输出.如如何实现printf("%I128d",i)来输出这个数字.

解决方案 »

  1.   

    http://sourceforge.net/projects/cpp-bigint/
    C++ class BigInt that enables the user to work with arbitrary precision integers.
      

  2.   

    struct __int128
    {
      byte data[128/8];
    }再重载几个基本的运算符,应该可以实现的。
      

  3.   

    算法里经常用大数,目前rsa算法vc版基本上都支持4096位计算了,里面大数+-*/都支持。
      

  4.   

    看看这个
    http://it.china-b.com/cxsj/vc/20090612/102463_1.html
      

  5.   

    http://download.csdn.net/source/513886
      

  6.   

    自己union定义个结构来实现.. 但超过32位的变量貌似都非原子了. 所以多线程要lock
      

  7.   

    http://www.pudn.com/downloads2/sourcecode/windows/other/detail4334.html
    http://www.cppblog.com/xuchaoyi99/archive/2005/12/04/1530.aspx
    http://topic.csdn.net/t/20060815/10/4950189.html
      

  8.   


    struct _int128
    {
      int i1;
      int i2;
      int i3;
      int i4;
    }
      

  9.   

    多说两句.给后来的有用的人提个醒:Miracl库和CXWord类都是不错的方案. 但前者不支持运算符, 比较遗憾.