简体   繁体   English

大数除法返回1 [c ++]

[英]Large Numbers Division returns 1 [c++]

I am new here so i am sorry if my question is a kind stupid, but, i was calculating the divisions of two large numbers and storing them in an array, like this: 我是新来的,如果我的问题有点愚蠢,对不起,但是,我正在计算两个大数的除法,并将它们存储在数组中,如下所示:

int det(double M[25][25], int m)
{
    /*returns large numbers*/
}

int main()
{
    float y[27];
    double A[25][25] = {0}, N = 26, D = -134430487042201894894174208;

    y[0] = 0;
    y[26] = 1;

    for (int i = 0; i < N-1; i++)
    {
        //Reset A[][] to the original
        for (int k = 0; k < N-1; k++)
        {
            for (int J = 0; J < N-1; J++)
                {
                    A[k][J] = m[k][J];
                }
        }
        //Change values of A[j][i]
        for (int j = 0; j < N-1; j++)
          {
              A[j][i] = d[j+1];
          }
        y[i+1] = det(A,N-1)/D; //Here y returns only 0, 1, 1, 1, 1, ...
    }
}D

So, what am i doing wrong? 那么,我在做什么错呢? y array returns 0, 1, 1, 1, 1, ... , and it was supposed to not be 1 y数组返回0,1,1,1,1,...,应该不是1

det(A,N-1) = 7958284334509567005163520 D = -134430487042201894894174208 det(A,N-1)= 7958284334509567005163520 D = -134430487042201894894174208

det(A,N-1)/D = -0.05919999629259109195883585509348322869497780932400145347... det(A,N-1)/ D = -0.05919999629259259109195883585509348322322497780932400145347 ...

It's not 1. 不是1。

Thanks! 谢谢!

The function det is returning an int. 函数det返回一个int。 You are never going to get floating point values from it. 您永远不会从中获取浮点值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM