Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
January 10, 2004 XOR | ||||
---|---|---|---|---|
| ||||
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. |
January 10, 2004 Re: XOR | ||||
---|---|---|---|---|
| ||||
Posted in reply to Phill | 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);
|
January 10, 2004 Re: XOR | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | 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); > |
January 11, 2004 Re: XOR | ||||
---|---|---|---|---|
| ||||
Posted in reply to Phill | 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. > > > > > |
January 11, 2004 Re: XOR | ||||
---|---|---|---|---|
| ||||
Posted in reply to Phill | 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. > > > > > > > > > > > > |
January 11, 2004 Re: XOR | ||||
---|---|---|---|---|
| ||||
Posted in reply to Phill | 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
|
January 11, 2004 Re: XOR | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | 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 |
Copyright © 1999-2021 by the D Language Foundation