In a program i have to calculate pow(2,N) where 0<N<=1000. which data type is suitable for this?
I have used unsigned long long int but its range is also limited.
shanki himanshu
27
Light Poster
Recommended Answers
Jump to Postthe function pow() returns double. So you can use double to hold the value.
using namespace std; int main() { double i; i = pow(2,1000); cout<<i<<endl; //prints 1.07151e+301 i = i*4; cout<<i<<endl; //prints 4.28603e+301 i = pow(i,((double)1/1002)); cout<<i<<endl; //prints 2 return 0; }
Jump to Postthe function pow() returns double. So you can use double to hold the value.
using namespace std; int main() { double i; i = pow(2,1000); cout<<i<<endl; //prints 1.07151e+301 i = i*4; cout<<i<<endl; //prints 4.28603e+301 i = pow(i,((double)1/1002)); cout<<i<<endl; //prints 2 return 0; }
this is the c forum …
All 6 Replies
subith86
17
Junior Poster
zeroliken
79
Nearly a Posting Virtuoso
shanki himanshu
27
Light Poster
subith86
17
Junior Poster
shanki himanshu
27
Light Poster
subith86
17
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.