Hi everyone, I'm trying to figure out if there is any way to do exponents using bit shifting. I know the following: x *= 2 --> x << 2 x /= 2 --> x >> 2 pow(2, x) --> 1 << x i'm looking for the equivalent bitshift, if any, for x = pow(x, 2) where x can be any number i've seen the following for x = 5 x = 0101 (5) x << 2 --> 010100 (20) x + 0101 --> 011001 (25) but then that is not true for other numbers :( +0 I am making a program to store all the powers of 2(1,2,4,8...) till 2 ^50000. Although I am getting the answer,I am not getting my answer in the required time limit. Any suggestions? How should I store the numbers? Here is my stupid code as of now [CODE] #include #include #include int bin; int main() { int n; int t,i,j; scanf("%d",&t); while(t--){ scanf("%d",&n); for(i=0;i<16604;i++) { bin[i]=0; } bin=1; //bin=3; int temp=0,x=0; for( j=1;j<=n;j++) { for(i=16604;i>=0;i--) { temp=bin[i]*2+x; bin[i]=temp%10; x=temp/10; // printf("temp %d x %d bin[i] %d\n",temp,x,bin[i]); } temp=0;x=0; } int j; for( j=0;j<16604;j++) if(bin[j]) break; for( i=j;i<16604;i++) { printf("%d",bin[i]); } … +0 So I'm making a simple calculator program on the Windows Form Application of C++. Nevertheless, I'm stuck on the exponents, factorial, and square root part. In my System32 Console calculator, these were the codes I use for the exponent, factorial, and respectively, while I just used the sqrt function of math.h library for the square root: [CODE]cout<<"Ingrese su base : "; cin>>VAL1; cout<<"\n Ingrese su potencia : "; cin>>VAL2; ACUMULADO=VAL1; if (VAL2==1) { RES=VAL1; cout<<"\n Su respuesta es : "<1) { for … +0 Hi I have a problem with some code. Basically what the program is supposed to do is to take in a minimum exponent and a maximum exponent and a base. Then its is suppose to create a table displaying the base to the power of the minimum exponent to the max exponent.I have got the positive exponents to work but I cannot get the negative exponents to work. I cannot use the pow() function. ex.(this is what it should look like) input: Base = 2 max exponent = 3 min exponent = -2 output: .25 .5 1 2 4 8 … +0

The End.