how to overcome runtime error signal:25? equivalently, floating point error: core dumped?

338 views Asked by At

so i've made this function for printing big primes between the interval L,U:
1. This function runs correctly for small numbers.
2. When I try to print the primes between two big numbers(for example, 100000000 and 100100000),
on IDEONE.com, it says: runtime error signal:25
on linux(using terminal) it says: floating point exception (core dumped)

what might have gone wrong in this process of translation from small numbers to big numbers?

//primes[] stores all the primes between 2 and sqrt(1000000000)

    void check(long long L,long long U,long long primes[])
    {
        long long g=0,i=0,d;
        if(L==1)
        L++;
        long long v=sqrt(1000000000);
        for(long long k=L;k<U+1;k++)
        {
            i=0;
            d=sqrt(k);
            while(i<=v)     //this statement...
            {
                if(primes[i]<=d)
                {
                    if(k%primes[i]==0)
                    {g=1;break;}
                    ++i;
                }
                else
                break;
            }

            if(g==0)
            {
                cout<<k<<endl;
            }
            g=0;
        }
        return;
    }

EDIT: I solved the problem by eliminating the unused intervals from primes[] (check comments) from my calculations. This probably decreased the number of calculations by a lot (10x less calculations in the marked while statement.)Thanks to all those who responded.

1

There are 1 answers

1
Nihar On

check signature of

double sqrt(double x)

what is the max value it can take.