c++ - how to overcome runtime error signal:25? equivalently, floating point error: core dumped? -
so i've made function printing big primes between interval l,u:
1. function runs correctly small numbers.
2. when try print primes between 2 big numbers(for example, 100000000 , 100100000),
on ideone.com, says: runtime error signal:25
on linux(using terminal) says: floating point exception (core dumped)
what might have gone wrong in process of translation small numbers big numbers?
//primes[] stores primes between 2 , 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: solved problem eliminating unused intervals primes[] (check comments) calculations. decreased number of calculations lot (10x less calculations in marked while statement.)thanks responded.
check signature of
double sqrt(double x)
what max value can take.
Comments
Post a Comment