Velocity Reviews > Shorthand operator for AND, NOT

Shorthand operator for AND, NOT

Archos
Guest
Posts: n/a

 12-19-2011
Does exist a shorthand assignment operator to assign AND and NOT at
the same time? like &^=

Michael Haufe (TNO)
Guest
Posts: n/a

 12-19-2011
On Dec 19, 6:33*am, Archos <(E-Mail Removed)> wrote:
> Does exist a shorthand assignment operator to assign AND and NOT at
> the same time? like &^=

No. But with use of boolean algebra, there may be a simpler
representation anyway for you. !(a && b) == !a || !b

Archos
Guest
Posts: n/a

 12-19-2011
On Dec 19, 4:11*pm, "Michael Haufe (TNO)" <(E-Mail Removed)>
wrote:
> On Dec 19, 6:33*am, Archos <(E-Mail Removed)> wrote:
>
> > Does exist a shorthand assignment operator to assign AND and NOT at
> > the same time? like &^=

>
> No. But with use of boolean algebra, there may be a simpler
> representation anyway for you. !(a && b) == !a || !b

Then ,just for archiving, the assignment "&^=" would be:
a = a & b ^ a

Michael Haufe (TNO)
Guest
Posts: n/a

 12-21-2011
On Dec 19, 5:23*pm, Archos <(E-Mail Removed)> wrote:
> On Dec 19, 4:11*pm, "Michael Haufe (TNO)" <(E-Mail Removed)>
> wrote:
>
> > On Dec 19, 6:33*am, Archos <(E-Mail Removed)> wrote:

>
> > > Does exist a shorthand assignment operator to assign AND and NOT at
> > > the same time? like &^=

>
> > No. But with use of boolean algebra, there may be a simpler
> > representation anyway for you. !(a && b) == !a || !b

>
> Then ,just for archiving, the assignment "&^=" would be:
> a = a & b ^ a

You do realize that "^" is the XOR operator and not the NOT operator
right?

a = a & b ^ a

is equivalent to:
a = a & ~b

which is equivalent to:
a &= ~b

I still can't see a significant use case for "&^="

Archos
Guest
Posts: n/a

 12-22-2011
My fault. It's for bit clear

number &= ^(1 << x);

On Dec 21, 7:43*pm, "Michael Haufe (TNO)" <(E-Mail Removed)>
wrote:
> On Dec 19, 5:23*pm, Archos <(E-Mail Removed)> wrote:
>
> > On Dec 19, 4:11*pm, "Michael Haufe (TNO)" <(E-Mail Removed)>
> > wrote:

>
> > > On Dec 19, 6:33*am, Archos <(E-Mail Removed)> wrote:

>
> > > > Does exist a shorthand assignment operator to assign AND and NOT at
> > > > the same time? like &^=

>
> > > No. But with use of boolean algebra, there may be a simpler
> > > representation anyway for you. !(a && b) == !a || !b

>
> > Then ,just for archiving, the assignment "&^=" would be:
> > a = a & b ^ a

>
> You do realize that "^" is the XOR operator and not the NOT operator
> right?
>
> a = a & b ^ a
>
> is equivalent to:
> a = a & ~b
>
> which is equivalent to:
> a &= ~b
>
> I still can't see a significant use case for "&^="

Archos
Guest
Posts: n/a

 12-22-2011
number &= ~(1 << x);

On Dec 22, 8:44*am, Archos <(E-Mail Removed)> wrote:
> My fault. It's for bit clear
>
> number &= ^(1 << x);
>
> On Dec 21, 7:43*pm, "Michael Haufe (TNO)" <(E-Mail Removed)>
> wrote:
>
>
>
>
>
>
>
> > On Dec 19, 5:23*pm, Archos <(E-Mail Removed)> wrote:

>
> > > On Dec 19, 4:11*pm, "Michael Haufe (TNO)" <(E-Mail Removed)>
> > > wrote:

>
> > > > On Dec 19, 6:33*am, Archos <(E-Mail Removed)> wrote:

>
> > > > > Does exist a shorthand assignment operator to assign AND and NOT at
> > > > > the same time? like &^=

>
> > > > No. But with use of boolean algebra, there may be a simpler
> > > > representation anyway for you. !(a && b) == !a || !b

>
> > > Then ,just for archiving, the assignment "&^=" would be:
> > > a = a & b ^ a

>
> > You do realize that "^" is the XOR operator and not the NOT operator
> > right?

>
> > a = a & b ^ a

>
> > is equivalent to:
> > a = a & ~b

>
> > which is equivalent to:
> > a &= ~b

>
> > I still can't see a significant use case for "&^="

 Thread Tools

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post asit Java 4 07-03-2008 04:25 AM David W ASP .Net 0 01-17-2007 07:44 PM Foxpointe XML 4 10-31-2006 09:41 PM unspammable@gmail.com C++ 2 03-25-2005 10:38 PM Quean Computer Support 2 12-23-2004 07:08 AM

Advertisments