Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Raise value

Posted on 2011-02-20
Medium Priority
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;

            return 0;
Question by:mustish1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Author Comment

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

        newnumber = number^25;
LVL 53

Expert Comment

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


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

Open in new window

LVL 36

Assisted Solution

mccarl earned 400 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);
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 34939477
Microsoft Visual C++ 2010 Express
LVL 53

Expert Comment

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.

Author Comment

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

Accepted Solution

Infinity08 earned 1600 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


Author Closing Comment

ID: 34939513

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

618 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