Solved

Raise value

Posted on 2011-02-20
8
875 Views
Last Modified: 2012-05-11
Hi guys: Can any one please tell me how to i raise the number 2 upto the 25th power and assign it to the double variable ? Thanks.

#include <iostream>
using namespace std;

int main()
{
      int number = 2;
        double newnumber = 0.00;


            system("pause");
            return 0;
}  
0
Comment
Question by:mustish1
  • 4
  • 3
8 Comments
 

Author Comment

by:mustish1
ID: 34939307
I tried this line but it says 27 its wrong

        newnumber = number^25;
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 34939467
You're looking for the pow function in the standard C math.h header file :

        http://cplusplus.com/reference/clibrary/cmath/pow/

For example :
double result = pow(2.0, 25.0);

Open in new window

0
 
LVL 35

Assisted Solution

by:mccarl
mccarl earned 100 total points
ID: 34939470
I am guessing from the code you are using C or C++, but what environment are you using? (Linux, Windows, and Visual C, .NET, Borland, etc)

But anyway, you might have some function that you can call like...  double newnumber = pow(2, 25);
0
 

Author Comment

by:mustish1
ID: 34939477
Microsoft Visual C++ 2010 Express
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 53

Expert Comment

by:Infinity08
ID: 34939484
The IDE you use doesn't make a difference. The pow function is in the standard C library, and is available in any standards compliant C or C++ compiler. See the reference page in my first post for more information.
0
 

Author Comment

by:mustish1
ID: 34939492
Thanks is there any way i can do this with a 3GL logic without using pow function.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 400 total points
ID: 34939500
If you are asking whether there is a built-in operator that does this, then no. The standard way of doing it, is by using the pow function.


If you are specifically asking about powers of 2, you could use the left-shift operator, but that has a very limited field of application obviously :
uint32_t result = 0x1 << 25;

Open in new window

0
 

Author Closing Comment

by:mustish1
ID: 34939513
Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 126
Need To Find FireFox Binary Path For Python Selenium On Windows 7 15 444
python question 5 69
Arduino EDI - Programming language 3 80
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This is about my first experience with programming Arduino.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now