^ 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.

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through resources like this. We hope you find it helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support here. If you need help with a problem please use one of the many online forums.

Comments

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