Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::pow

 

std::pow is a mathematical STL function to take the power of two doubles.

 

 

To take the power of two integers, use IntPower instead.

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppPow.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2012-01-28T16:44:39
#
#-------------------------------------------------

QT       += core

QT       -= gui

TARGET = CppPow
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp

 

 

 

 

 

main.cpp

 

#include <cmath>
#include <iostream>

int main()
{
  const double base = 1.1;
  const double exponent = 2.2;
  const double result = std::pow(1.1,2.2);
  std::cout << base << " to the power of " << exponent << " is " << result << '\n';
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml