• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Power operator in C++

I thought it was the ^ operator... but it's giving me weird results. I need to parse consecutive integers in an array to be one whole number.

So 234 would get input as [2|3|4] in an array

So I count digits, so the number = 2*10^2 + 3*10^1 + 4*10^0 = 234

which works right AFAIK, and its not an operator precedence thing because I've confirmed values with cout. It's just that the power doesn't work right. Any ideas?


Now, why I'm spending time on this when the other 98% of my program is completely hosed, I don't know but this is the only way to parse the input into a single number that I can think of.
 
C++ doesn't have a power operator, it uses a function (pow).

FYI it's a good idea to find C/C++ docs and RTFM when you get stuck, you'll get your answer right away and people won't mock your RTM skills 🙂
 
lmao. that's a pretty common misunderstanding.

^ is bitwise exclusive or

like Dave said, use std:😛ow() (include <cmath>)
 
Back
Top