C++编译器自带的四则运算对于数据的范围是有要求,对于位数很高的数据的四则运算就无能为力,例如,12378456179787565453232321218784545121123132121132178767655657与11231548785127851的和。
请用设计一个类完成无符号大整数的四则运算,加减法是必须实现的,乘除法选做。
【】最大的问题就是进位那地方的代码,感觉很乱,确实不会
谢谢各位了
PHP中文网2017-04-17 11:59:46
http://www.boost.org/doc/libs/1_58_0/libs/multiprecision/doc/html/boos...
大家讲道理2017-04-17 11:59:46
The first thing to solve is the storage method of large numbers. The options are: 1). Store as strings; 2). Store as linked lists...
There is a question on Leetcode about adding large numbers stored in linked lists, for reference.
https://leetcode.com/problems/add-two-numbers/
You can find many references in the corresponding discussion:
https://leetcode.com/discuss/questions/oj/add-two-numbers
Promote my answer:
https://github.com/braydenCN/leetcode/blob/master/com/brayden/AddTwoNu...
Subtraction of large numbers, or problems of large numbers stored in strings, can be solved similarly.