How to implement big int in C++

前端 未结 13 1893
攒了一身酷
攒了一身酷 2020-11-22 07:48

I\'d like to implement a big int class in C++ as a programming exercise—a class that can handle numbers bigger than a long int. I know that there are several open sou

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 08:08

    If your target architecture supports BCD (binary coded decimal) representation of numbers, you can get some hardware support for the longhand multiplication/addition that you need to do. Getting the compiler to emit BCD instruction is something you'll have to read up on...

    The Motorola 68K series chips had this. Not that I'm bitter or anything.

提交回复
热议问题