Large Numbers Division returns 1 [c++]

94 views Asked by At

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

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

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

It's not 1.

Thanks!

1

There are 1 answers

1
ttemple On BEST ANSWER

The function det is returning an int. You are never going to get floating point values from it.