Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Error for & operator

Status
Not open for further replies.

anjanesh

Programmer
Mar 10, 2003
13
IN
Why is cout << (double(23) & pow(2,5)); giving an error ?

C:\xxx\xxx.cpp(12) : error C2296: '&' : illegal, left operand has type 'double'
C:\xxx\xxx.cpp(12) : error C2297: '&' : illegal, right operand has type 'double'

Both should be double. We cant convert the pow to int as the value wont be visible if it crossess the 32768 mark ?
Thanks

 
Because the bit operator & is for integers.

/Per

www.perfnurt.se
 
What are you trying to do? You've written something like, "Output an integer composed of the bits that are set in both 23 (as a double) and the result of [tt]pow(2,5)[/tt] (also as a double)." Your compiler has wisely protected you from doing something that doesn't appear to make any sense.
 
BTW, unless you're compiling on DOS, an int has a range of -2147483648 to 2147483647, not -32768 to 32767.
If you use an unsigned int you could squeeze that range a bit higher from 0 to 4294967295.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top