www.digitalmars.com         C & C++   DMDScript  

D - XOR

reply "Phill" <phill pacific.net.au> writes:
Hi there
With DMC++ and the following code I get what
I expect from the following code:
------------------------
int test = 108 ^ 100;
 printf("test =");
cout << test << endl;

test=8
------------------
But when using D with the same code
I get
test = 89

Is there a special way to do the XOR with
D or is this a bug?

Phill.
Jan 09 2004
next sibling parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
Phill wrote:

Hi there
With DMC++ and the following code I get what
I expect from the following code:
------------------------
int test = 108 ^ 100;
 printf("test =");
cout << test << endl;

test=8
------------------
But when using D with the same code
I get
test = 89

Is there a special way to do the XOR with
D or is this a bug?

Phill.



  
Works for me int test = 108 ^ 100; printf("%d", test);
Jan 09 2004
parent "Phill" <phill pacific.net.au> writes:
Thanks !

In the D file I was using
toString(test)
 instead of
printf("%d", test);

Phill.

"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:btnv2k$g7$1 digitaldaemon.com...
 Phill wrote:

Hi there
With DMC++ and the following code I get what
I expect from the following code:
------------------------
int test = 108 ^ 100;
 printf("test =");
cout << test << endl;

test=8
------------------
But when using D with the same code
I get
test = 89

Is there a special way to do the XOR with
D or is this a bug?

Phill.
Works for me int test = 108 ^ 100; printf("%d", test);
Jan 09 2004
prev sibling parent reply "Phill" <phill pacific.net.au> writes:
Well how about this ?

int number = 107 ^ 100;
printf("number =");
printf("%d", number);

I believe "number" should be 7
but it prints
number=15

Phill.



"Phill" <phill pacific.net.au> wrote in message
news:btnulg$8l$1 digitaldaemon.com...
 Hi there
 With DMC++ and the following code I get what
 I expect from the following code:
 ------------------------
 int test = 108 ^ 100;
  printf("test =");
 cout << test << endl;

 test=8
 ------------------
 But when using D with the same code
 I get
 test = 89

 Is there a special way to do the XOR with
 D or is this a bug?

 Phill.
Jan 10 2004
next sibling parent "Phill" <phill pacific.net.au> writes:
woops, forget the last post (blush)

Phill

"Phill" <phill pacific.net.au> wrote in message
news:btq5j7$lfc$1 digitaldaemon.com...
 Well how about this ?

 int number = 107 ^ 100;
 printf("number =");
 printf("%d", number);

 I believe "number" should be 7
 but it prints
 number=15

 Phill.



 "Phill" <phill pacific.net.au> wrote in message
 news:btnulg$8l$1 digitaldaemon.com...
 Hi there
 With DMC++ and the following code I get what
 I expect from the following code:
 ------------------------
 int test = 108 ^ 100;
  printf("test =");
 cout << test << endl;

 test=8
 ------------------
 But when using D with the same code
 I get
 test = 89

 Is there a special way to do the XOR with
 D or is this a bug?

 Phill.
Jan 10 2004
prev sibling parent reply Andy Friesen <andy ikagames.com> writes:
Phill wrote:
 Well how about this ?
 
 int number = 107 ^ 100;
 printf("number =");
 printf("%d", number);
 
 I believe "number" should be 7
 but it prints
 number=15
 
 Phill.
No, 15 is right. 01101011 - 107 01100100 - 100 00001111 - 15 -- andy
Jan 10 2004
parent "Phill" <phill pacific.net.au> writes:
yep, thats why I said
"woops, forget the last post (blush)"

Phill.

"Andy Friesen" <andy ikagames.com> wrote in message
news:btq5t1$lsc$1 digitaldaemon.com...
 Phill wrote:
 Well how about this ?

 int number = 107 ^ 100;
 printf("number =");
 printf("%d", number);

 I believe "number" should be 7
 but it prints
 number=15

 Phill.
No, 15 is right. 01101011 - 107 01100100 - 100 00001111 - 15 -- andy
Jan 10 2004