www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - constants and power

reply Manfred Nowak <svv1999 hotmail.com> writes:
<code>
void main(){
  const int num1 = 10^2;
  const int num2 = 100^2;
  const int num3 = 1000^3;
  printf("%d %d %d\n", num1, num2, num3);
}
</code>

<output>
8 102 1003
</output>

-manfred
Jan 24 2005
parent reply Lukas Pinkowski <Lukas.Pinkowski web.de> writes:
Manfred Nowak wrote:

 <code>
 void main(){
   const int num1 = 10^2;
   const int num2 = 100^2;
   const int num3 = 1000^3;
   printf("%d %d %d\n", num1, num2, num3);
 }
 </code>
 
 <output>
 8 102 1003
 </output>
 
 -manfred

"^" is the XOR-Operator not power. i.e. 10 dec = 0b1010 in binary 0b1010 ^ 0b10 = 0b1000 0b1000 is 8 in decimal
Jan 24 2005
parent Manfred Nowak <svv1999 hotmail.com> writes:
Lukas Pinkowski wrote:

[...]

 "^" is the XOR-Operator

Arghhhh, severe black out on my side :-( Thx. -manfred
Jan 24 2005