Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 24, 2004 Idea: Bit clear | ||||
---|---|---|---|---|
| ||||
We can already set specific bits with a single operator so i think it would be a nice feature to be able to clear them with a single operator. Eg somthing like... val = val !! 7; would be much clearer than either of... val = (val | 7) ^ 7; val = val & (!7); I am not even sure !7 actualy be converted to the correct bit mask anyway? Is the compiler smart enough to make the bitmask the same width as the variable? At least it does not seem obvious what width the !7 should be. With a bit clear operator it is explicit what width the bitmask should be. And it may be of benefit for processors (like the StrongArm) that have a bit clear instruction. Mabey even x86 will some day. cheers, chris |
April 24, 2004 Re: Idea: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris | <snip>
>We can already set specific bits with a single operator so i think it would be a nice feature to be able to clear them with a single operator. Eg somthing
</snip>
Oh no, not more operators!
Have you read up on Intrinsic Functions?
Were it not for those I'd suggest adding member functions int.BitTest(int),
int.BitSet(int), and int.BitClear(int) -- but they would make it difficult to
mimic x = y op z
|
April 24, 2004 Re: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris | From: "chris" <news@flak.clara.co.uk> > We can already set specific bits with a single operator so i think it would be a > nice feature to be able to clear them with a single operator. Eg somthing like... val &= ~7; |
April 24, 2004 Re: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | "Vathix" <vathix@dprogramming.com> wrote in message news:c6cgp3$2qlt$1@digitaldaemon.com... > From: "chris" <news@flak.clara.co.uk> > > > We can already set specific bits with a single operator so i think it > would be a > > nice feature to be able to clear them with a single operator. Eg somthing like... > > val &= ~7; what does "~" do? It is listed under "Add Expresions" but i still dont follow what it does. cheers, chris |
April 24, 2004 Re: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris | chris wrote:
>
> what does "~" do? It is listed under "Add Expresions" but i still dont follow
> what it does.
Array concatenation (and thus also string concatenation).
Lars Ivar
|
April 24, 2004 Re: Idea: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juan C | "Juan C" <Juan_member@pathlink.com> wrote in message news:c6cgog$2qlh$1@digitaldaemon.com... > <snip> > >We can already set specific bits with a single operator so i think it would be a > >nice feature to be able to clear them with a single operator. Eg somthing > </snip> > > Oh no, not more operators! > > Have you read up on Intrinsic Functions? I didnt know about those but from the docs it seems the only functions are for setting / clearing single bits by index. cheers, chris |
April 24, 2004 Re: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:c6dm4f$281$1@digitaldaemon.com... > chris wrote: > > > > what does "~" do? It is listed under "Add Expresions" but i still dont follow > > what it does. > > Array concatenation (and thus also string concatenation). i am confused.... so what does his example do? Ie... val &= ~7; chris |
April 24, 2004 Re: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris | "chris" <news@flak.clara.co.uk> wrote: > i am confused.... so what does his example do? Ie... > > val &= ~7; When used as a unary operator, '~' is bit-wise NOT, whereas '!' is a unary logical NOT. Same as in C and C++. -- dave |
April 24, 2004 Re: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave Sieber | "Dave Sieber" <dsieber@spamnot.sbcglobal.net> wrote in message news:Xns94D53C42924D8dsiebersbc@63.105.9.61... > "chris" <news@flak.clara.co.uk> wrote: > > > i am confused.... so what does his example do? Ie... > > > > val &= ~7; > > When used as a unary operator, '~' is bit-wise NOT, whereas '!' is a unary logical NOT. Same as in C and C++. ah, makes sense now. Cheers. It is not listed in the "Bitwise Epresions" docs btw. chris |
April 24, 2004 Re: Bit clear | ||||
---|---|---|---|---|
| ||||
Posted in reply to chris | ~ is unary bitwise not "chris" <news@flak.clara.co.uk> wrote in message news:c6dltq$254$1@digitaldaemon.com... > > "Vathix" <vathix@dprogramming.com> wrote in message news:c6cgp3$2qlt$1@digitaldaemon.com... > > From: "chris" <news@flak.clara.co.uk> > > > > > We can already set specific bits with a single operator so i think it > > would be a > > > nice feature to be able to clear them with a single operator. Eg somthing like... > > > > val &= ~7; > > what does "~" do? It is listed under "Add Expresions" but i still dont follow what it does. > > cheers, > > chris > > |
Copyright © 1999-2021 by the D Language Foundation