Squaring problem
your problem is the ^ operator, is doesn''t square.
10 is binary 1010
2 is binary 0010...
8 is binary 1000
found any pattern?
^ is logical XOR operator.
10 is binary 1010
2 is binary 0010...
8 is binary 1000
found any pattern?
^ is logical XOR operator.
-----The scheduled downtime is omitted cause of technical problems.
ten in binary 1010
two in binary 0010
----
xor''ed binary 1000 = eight
----
two in binary 0010
----
xor''ed binary 1000 = eight
----
quote:
Original post by peter86
What operator is square then?
^ is normally used as square.
10 * 10
[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]
quote:
^ is normally used as square
er... 'normally' isn't how computer languages work.
c++ only has division, muliplication, modulo, addition, subtraction as part of the language.
the maths libraries are used for trigonometric functions etc
so you #include <cmath> and use std:: pow to multiply a number up by a power
#include <cmath>using std::pow;const int ten = 10;const int two = 2;const int hundred = pow(ten, two); //or just do 10*10
Do you not have a good reference manual for c/c++? You have often asked questions about basic syntax, keywords and concepts. Most people will look them up themselves.
If you don't have money for books then bookmark these links - they'll open in new windows.
c++ faq
thinking in c plus plus book
Also if you are using MSVC++ it comes with documentation. Click Help->Contents and type '^'.
[edited by - petewood on January 6, 2003 7:07:20 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement