bitwise operations


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: bitwise operations

  1. #1
    Rob Teixeira Guest

    bitwise operations


    Amidst all the feverish discussion about boolean and bitwise stuff, someone
    mentioned that in a good type-safe language, even numerical data should be
    shielded from bitwise operations, and only bit types would allow it.
    Well, there actually is a class for bitwise information. It's called BitVector,
    and IMO, it's much cooler than bitwise And/Or for working with flags and
    masks.

    -Rob

  2. #2
    Jonathan Allen Guest

    Re: bitwise operations

    Beta 1: BitVector32 is missing things like Bit Shifting.

    --
    Jonathan Allen


    "Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
    news:3ad3cd10$1@news.devx.com...
    >
    > Amidst all the feverish discussion about boolean and bitwise stuff,

    someone
    > mentioned that in a good type-safe language, even numerical data should be
    > shielded from bitwise operations, and only bit types would allow it.
    > Well, there actually is a class for bitwise information. It's called

    BitVector,
    > and IMO, it's much cooler than bitwise And/Or for working with flags and
    > masks.
    >
    > -Rob




  3. #3
    Bill McCarthy Guest

    Re: bitwise operations

    Gee thanks for that incredibly insightfull post JA. I know you have trouble
    with bitshifting and bitwise operation concepts, actually I still get a
    laugh over that bug ridden code you posted to the MS.public newsgroups
    claiming it as a replacement for bitshifting. LOL. But in anycase how what
    you say here relevent to the discussion. Rob clearly stated bitwise And/Or
    and masks.



    "Jonathan Allen" <greywolf@cts.com> wrote in message
    news:3ad3e6e9@news.devx.com...
    > Beta 1: BitVector32 is missing things like Bit Shifting.
    >
    > --
    > Jonathan Allen
    >
    >
    > "Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
    > news:3ad3cd10$1@news.devx.com...
    > >
    > > Amidst all the feverish discussion about boolean and bitwise stuff,

    > someone
    > > mentioned that in a good type-safe language, even numerical data should

    be
    > > shielded from bitwise operations, and only bit types would allow it.
    > > Well, there actually is a class for bitwise information. It's called

    > BitVector,
    > > and IMO, it's much cooler than bitwise And/Or for working with flags and
    > > masks.
    > >
    > > -Rob

    >
    >




  4. #4
    Bill McCarthy Guest

    Re: bitwise operations

    Hi Rob,

    yeh an interesting little collection class, however I don't think it very
    practical for things such as setting the flags for a common dialog, do you ?


    "Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
    news:3ad3cd10$1@news.devx.com...
    >
    > Amidst all the feverish discussion about boolean and bitwise stuff,

    someone
    > mentioned that in a good type-safe language, even numerical data should be
    > shielded from bitwise operations, and only bit types would allow it.
    > Well, there actually is a class for bitwise information. It's called

    BitVector,
    > and IMO, it's much cooler than bitwise And/Or for working with flags and
    > masks.
    >
    > -Rob




  5. #5
    Rob Teixeira Guest

    Re: bitwise operations


    To be quite honest, with an average of 64MB of ram to play with, I don't see
    a need for bit-flagging at all (outside of compatibility to old code). If
    I have an entity, and attributes need to be set for it, they are far better
    implemented as independant properties - even if the property accessor and
    mutator (get/set) work from a bitvector, which may be a product of legacy
    code. At least that's how I see it.

    I pointed out the bitvector class simply because someone mentioned that bit
    manipulation should have it's own type

    -Rob

    "Bill McCarthy" <bill_mcc@iprimus.com.au> wrote:
    >Hi Rob,
    >
    >yeh an interesting little collection class, however I don't think it very
    >practical for things such as setting the flags for a common dialog, do you

    ?
    >
    >
    >"Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
    >news:3ad3cd10$1@news.devx.com...
    >>
    >> Amidst all the feverish discussion about boolean and bitwise stuff,

    >someone
    >> mentioned that in a good type-safe language, even numerical data should

    be
    >> shielded from bitwise operations, and only bit types would allow it.
    >> Well, there actually is a class for bitwise information. It's called

    >BitVector,
    >> and IMO, it's much cooler than bitwise And/Or for working with flags and
    >> masks.
    >>
    >> -Rob

    >
    >



  6. #6
    Bill McCarthy Guest

    Re: bitwise operations

    Hi Rob,

    "Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
    news:3ad4b377$1@news.devx.com...
    >
    > To be quite honest, with an average of 64MB of ram to play with, I don't

    see
    > a need for bit-flagging at all (outside of compatibility to old code). If
    > I have an entity, and attributes need to be set for it, they are far

    better
    > implemented as independant properties - even if the property accessor and
    > mutator (get/set) work from a bitvector, which may be a product of legacy
    > code. At least that's how I see it.
    >


    Hmm. well I do really disagree on that. I have code here (.net beta1) that
    calls the RAS api. one field in the RasEntry struct is the options, which is
    about 20 or 30 or so flags. If I had to write a property for each one, not
    only would it be time consuming and make the code even larger (aside from
    the perf hit of course), but it would also make databinding with it even
    harder, and require people using the component to write say 20 lines of code
    instead of just one.

    Bitwise Enums (using the Flags() attribute) are part of the .NET framework,
    and as far as I am concerned ar really part of programming, especially
    programming for MS Windows.














  7. #7
    Rob Teixeira Guest

    Re: bitwise operations


    Just goes to show that there's theory, and then there's practice.
    I hate obfuscating properties by setting flags, but there are cases, as you
    point out, where flags win.
    At any rate, anything that's ever been written in C++ and has a legacy of
    over five years is bound to be chalk-full of flags and masks.

    -Rob

    "Bill McCarthy" <bill_mcc@iprimus.com.au> wrote:
    >Hi Rob,
    >
    >"Rob Teixeira" <RobTeixeira@@msn.com> wrote in message
    >news:3ad4b377$1@news.devx.com...
    >>
    >> To be quite honest, with an average of 64MB of ram to play with, I don't

    >see
    >> a need for bit-flagging at all (outside of compatibility to old code).

    If
    >> I have an entity, and attributes need to be set for it, they are far

    >better
    >> implemented as independant properties - even if the property accessor

    and
    >> mutator (get/set) work from a bitvector, which may be a product of legacy
    >> code. At least that's how I see it.
    >>

    >
    >Hmm. well I do really disagree on that. I have code here (.net beta1) that
    >calls the RAS api. one field in the RasEntry struct is the options, which

    is
    >about 20 or 30 or so flags. If I had to write a property for each one, not
    >only would it be time consuming and make the code even larger (aside from
    >the perf hit of course), but it would also make databinding with it even
    >harder, and require people using the component to write say 20 lines of

    code
    >instead of just one.
    >
    >Bitwise Enums (using the Flags() attribute) are part of the .NET framework,
    >and as far as I am concerned ar really part of programming, especially
    >programming for MS Windows.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center