小编use*_*490的帖子

HugeInt的重载除法运算符

可能重复:
分数非常大

我需要重载/运算符来处理两个HugeInt对象,它们被简单地定义为30个短裤的数组.这是家庭作业,顺便说一句,但是我已经在这个问题上花了好几天的时间.

我已经重载了*运算符:

HugeInt HugeInt::operator*(const HugeInt &op2){
HugeInt temp;
short placeProducts[hugeIntSize + 1][hugeIntSize] = {0};
short product;
int carry = 0;
int k, leftSize, rightSize, numOfSumRows;

leftSize = getDigitLength();
rightSize = op2.getDigitLength();

if(leftSize <= rightSize) {

    numOfSumRows = leftSize;

    for(int i = (hugeIntSize - 1), k = 0; k < numOfSumRows; i--, k++) {

        for(int j = (hugeIntSize - 1); j >= k; j--) {

            product = integer[i] * op2.integer[j] + carry;

            if (product > 9) {

                carry = …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm math division

5
推荐指数
1
解决办法
1805
查看次数

标签 统计

algorithm ×1

c++ ×1

division ×1

math ×1