cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Exponents
Exponents
Mar 12, 2013 at 12:38am UTC
Bolong Yu
(73)
In math, a number t times itself is t^2. Is it the same thing in C++?
Mar 12, 2013 at 12:40am UTC
Zhuge
(4664)
In C++, the ^ character represents a bitwise XOR operation, which is not the same as exponentiation. To raise to a power just multiply (e.g. t*t in your case) or use the pow() function.
Mar 12, 2013 at 12:42am UTC
Yanson
(885)
no use the pow function in the <cmath> header.
http://www.cplusplus.com/reference/cmath/pow/
Topic archived. No new replies allowed.