Hey can anyone tell me, that if i want to make a program which test whether a no is prime or nt for all integers and also for nos above the range of integer. Is there any way. Do i need to set my own range. pls tell me a way.

# Result for number aboove its range

0

If no built in types fit the range you want to test then you'll have to define your own type and encode the operations you want to use. This isn't as difficult as it sounds; there's already an example of how we normally do that in this reply, i.e. the number 32 - no single digit has a value greater than 9, so we use multiple digits to represent numbers larger than 9. So you can use multiple ints to represent numbers larger than 2^(8*sizeof int), for example int bignum[4] will represent a number up to 2^(4*8*sizeof int).

Then you will need to write code to add these, because the built in operators only know about built in types. Again this is fairly easy; just remember how you did it on paper then write code to do that, for example:

1234

5678+

====

4+8=12, so write 2 below 4 and 8 and carry the 1. 3+7=10, add the carry=11, write 1, carry 1.

2+6=8, add carry=9, write 9. 1+5=6.

So in code you might have something like (simplified):

Code:

int bignum1[4]={1,2,3,4}; int bignum2[4]={5,6,7,8}; int bugnum3[4]={0,0,0,0}; // this will contain the sum int carry=0; for (int i=3; i>=0; i--) { bignum3[i]=bignum1[i]+bignum2[i]+carry; carry=0; if (bignum3[i]>10) { bignum3[i]-=10; carry=1; } }

0

so i wrote

unsigned long long atoi1(char s[])

{

unsigned long long m=0;

int i;

for(i=0;s[i]>='0' && s[i]<='9';++i)

m=10*m+(s[i]-'0');

return m;

}

in main i create an array which takes the no string from user

and with the help of this func it converts it into long long

again it is giving negative result on exceeding the value from 32767

ie 16 bit

0

I tried the above code and it worked fine with 1048576, using Visual Studio 2005.

0

oh i should try %ld, is this the prob. let me check it on visual studio