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 "&^="