Extreme newbie help

I don't understand why this doesn't work.
Actually I understand it somewhat because the compiler told me
"invalid operands of types "double" and "int" to binary "operator^"
So this I'm guessing means that I cant place the int and the ^ inside of double?

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>
using namespace std;

int main()
{
    double G = 6.673*10^-11;
    cout << G << endl;

    return 0;
}


Help appreciated!
The ^ operator does not mean 'to the power of', but it is the bitwise exclusive or operator: http://www.cprogramming.com/tutorial/bitwise_operators.html
In C++ no 'to the power of' operator exists, you can use this function: http://www.cplusplus.com/reference/cmath/pow/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <cmath>
#include <iostream>
#include <iomanip>

int main()
{
    const double G = 6.67384e-11 ; // 6.67384 * 10^-11 as a literal
    const double e = 2.718281828459 ;
    const double G_to_the_power_e = std::pow( G, e ) ; // computed at run-time

    std::cout << G << '\n' ; // 6.67384e-011
    std::cout << std::fixed << std::setprecision(17) << G << '\n' ; // 0.00000000006673840
    std::cout << std::scientific << std::setprecision(3) << G_to_the_power_e << '\n' ; // 2.187e-028
}
Thank you all math-genious, programmitous superhero men!
Topic archived. No new replies allowed.