^ is the character for Exponent (EXP on a calculator)

In C you use pow()

	pow(base, exponent)

In C you can use exponents in two places. Firstly, where numbers are so large or so small that decimal point notation is not human-readable. For instance 100,000,000,000 is best written as 1 * 10 ^11. Secondly where the program logic calls for a value to be raised to the power of another value.

For instance, say you have a virus multiplying in a large population, and each infected person infects another five on average before dying. How many people will be infected after N rounds? The answer is 5^N, or, in C, pow(5.0, N).

For mathematical reasons which are too involved to go into here the expression e^x has special characteristics, so it has its own function, exp(). The expression x^0.5, or sqrt(x) is also special and has its own function – here it is easy for a non-mathematician to see the value of this.

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.


Your email address will not be published. Required fields are marked *