P
pauldepstein
I have lines in my code like:
const int depth = 4;
int node_total = (depth + 1)^2;
This is giving a very different value for node_total than the seemingly
equivalent
int node_total = (depth + 1) * (depth + 1);
Why? What is the difference?
For example depth = 4; seems to lead to node_total == 7;
in my earlier version: int node_total = (depth + 1) ^2;
In other words, my first guess is that ^ is behaving like + (although I
would need more values to check this.)
Can anyone explain what ^ is doing?
As an incidental point, it is hard to google-search such inquiries --
the google search engine doesn't treat technical notation like ^ or ++
well at all, and is unable to judge what is "similar" to the
search-engine text.
I wonder if the google people are working on that (or if there is a
user's trick I'm missing.)
Paul Epstein
const int depth = 4;
int node_total = (depth + 1)^2;
This is giving a very different value for node_total than the seemingly
equivalent
int node_total = (depth + 1) * (depth + 1);
Why? What is the difference?
For example depth = 4; seems to lead to node_total == 7;
in my earlier version: int node_total = (depth + 1) ^2;
In other words, my first guess is that ^ is behaving like + (although I
would need more values to check this.)
Can anyone explain what ^ is doing?
As an incidental point, it is hard to google-search such inquiries --
the google search engine doesn't treat technical notation like ^ or ++
well at all, and is unable to judge what is "similar" to the
search-engine text.
I wonder if the google people are working on that (or if there is a
user's trick I'm missing.)
Paul Epstein