Algorithm newsgroup?

Discussion in 'C Programming' started by Paminu, Oct 5, 2005.

  1. Paminu

    Paminu Guest

    Where do I find an algorithm newsgroup?

    I am interested in getting some help with the "even parity check" algorithm.
    I used google to find this back in 1999 from this newsgroup:

    unsigned parity(unsigned arg)
    {
    unsigned a = arg;

    a ^= a >> 16;
    a ^= a >> 8;
    a ^= a >> 4;
    a ^= a >> 2;
    a ^= a >> 1;

    return a & 1;
    }

    Who have invented this algorithm?

    Is it possible to find an explanation somewhere because I see that it works
    but would never myself have come up with it and would very much like to
    know the theory behind it.
    Paminu, Oct 5, 2005
    #1
    1. Advertising

  2. "Paminu" <> wrote in message
    news:dhvurc$pv3$-c.dk...
    > Where do I find an algorithm newsgroup?


    I can only suggest a Russian one, fido7.ru.algorithms which would work for
    you only through a FIDO gateway and anyway most people there are Russian
    speaking, so, I'm not sure you'll find it suitable for you... :(

    > I am interested in getting some help with the "even parity check"

    algorithm.
    > I used google to find this back in 1999 from this newsgroup:
    >
    > unsigned parity(unsigned arg)
    > {
    > unsigned a = arg;
    >
    > a ^= a >> 16;
    > a ^= a >> 8;
    > a ^= a >> 4;
    > a ^= a >> 2;
    > a ^= a >> 1;
    >
    > return a & 1;
    > }
    >
    > Who have invented this algorithm?


    I have. Some Mr. John Brown has. Many people have invented that on their own
    independently.

    > Is it possible to find an explanation somewhere because I see that it

    works
    > but would never myself have come up with it and would very much like to
    > know the theory behind it.


    The explanation is simple: you XOR all bits of the number to get a single
    bit in the end. The above does it very well, and w/o an unnecessary loop, I
    must say.
    But this is all Off Topic in this group as you may know... So, I'm shutting
    up right here (had to do that in the beginning though).

    Alex
    Alexei A. Frounze, Oct 5, 2005
    #2
    1. Advertising

  3. Paminu

    Paminu Guest

    Alexei A. Frounze wrote:

    > "Paminu" <> wrote in message
    > news:dhvurc$pv3$-c.dk...
    >> Where do I find an algorithm newsgroup?

    >
    > I can only suggest a Russian one, fido7.ru.algorithms which would work for
    > you only through a FIDO gateway and anyway most people there are Russian
    > speaking, so, I'm not sure you'll find it suitable for you... :(
    >
    >> I am interested in getting some help with the "even parity check"

    > algorithm.
    >> I used google to find this back in 1999 from this newsgroup:
    >>
    >> unsigned parity(unsigned arg)
    >> {
    >> unsigned a = arg;
    >>
    >> a ^= a >> 16;
    >> a ^= a >> 8;
    >> a ^= a >> 4;
    >> a ^= a >> 2;
    >> a ^= a >> 1;
    >>
    >> return a & 1;
    >> }
    >>
    >> Who have invented this algorithm?

    >
    > I have. Some Mr. John Brown has. Many people have invented that on their
    > own independently.
    >
    >> Is it possible to find an explanation somewhere because I see that it

    > works
    >> but would never myself have come up with it and would very much like to
    >> know the theory behind it.

    >
    > The explanation is simple: you XOR all bits of the number to get a single
    > bit in the end. The above does it very well, and w/o an unnecessary loop,
    > I must say.
    > But this is all Off Topic in this group as you may know... So, I'm
    > shutting up right here (had to do that in the beginning though).
    >
    > Alex



    hmm but since there is only russian newsgroups covering algorithms would
    this group not be the most obvious group to discuss these kind of issues?

    If not is there any other alternatives?
    Paminu, Oct 5, 2005
    #3
  4. Paminu

    pete Guest

    Paminu wrote:

    > unsigned a = arg;
    >
    > a ^= a >> 16;


    That's undefined if UCHAR_MAX equals 0xffffu.

    --
    pete
    pete, Oct 5, 2005
    #4
  5. Paminu

    pete Guest

    Paminu wrote:
    >
    > Alexei A. Frounze wrote:
    >
    > > "Paminu" <> wrote in message
    > > news:dhvurc$pv3$-c.dk...
    > >> Where do I find an algorithm newsgroup?


    news:comp.programming

    --
    pete
    pete, Oct 5, 2005
    #5
  6. Paminu

    Skarmander Guest

    pete wrote:
    > Paminu wrote:
    >
    >
    >> unsigned a = arg;
    >>
    >> a ^= a >> 16;

    >
    >
    > That's undefined if UCHAR_MAX equals 0xffffu.
    >

    UINT_MAX, of course.

    And although you're right, we presumably aren't supposed to care.
    Otherwise a loop *would* be more appropriate, to accommodate unsigned
    ints of arbitrary sizes.

    S.
    Skarmander, Oct 5, 2005
    #6
  7. "Paminu" <> wrote in message
    news:di004u$q85$-c.dk...
    > hmm but since there is only russian newsgroups covering algorithms would
    > this group not be the most obvious group to discuss these kind of issues?
    >
    > If not is there any other alternatives?


    I simply don't know others. I prefer first to get my own solution, then look
    for any hint elsewhere if I don't like mine (e.g. too complicated, too slow)
    or if it's just incorrect/incomplete (e.g. doesn't cover the cases which I
    don't know at all or don't understand clearly). As for understanding why
    something works the way it does, if you have the code/formula for it, you
    generally can understand that, not always quickly, however, especially if
    either the formal language or the problem at hand (or both) isn't familiar
    to you. It all depends on the experience, level of ignorance, logical
    reasoning and researching skills, laziness and attitude, or, in other words,
    on your past, present and where you want to get with all that in the future.
    :)

    Alex
    Alexei A. Frounze, Oct 5, 2005
    #7
  8. Paminu

    pete Guest

    Skarmander wrote:
    >
    > pete wrote:
    > > Paminu wrote:
    > >
    > >
    > >> unsigned a = arg;
    > >>
    > >> a ^= a >> 16;

    > >
    > >
    > > That's undefined if UCHAR_MAX equals 0xffffu.
    > >

    > UINT_MAX, of course.


    Yes.

    --
    pete
    pete, Oct 5, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Important Newsgroup Virus Information

    Kevin Spencer, Sep 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,380
    William Ryan
    Sep 2, 2003
  2. Alex Yu
    Replies:
    1
    Views:
    1,378
    Tom Vande Stouwe MCSD.net
    Sep 3, 2003
  3. Fistandantilus

    Add-ins newsgroup

    Fistandantilus, Sep 15, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    387
    Dino Chiesa [MSFT]
    Sep 17, 2003
  4. Ahmed Moustafa
    Replies:
    0
    Views:
    767
    Ahmed Moustafa
    Nov 15, 2003
  5. Bapaiah Katepalli
    Replies:
    1
    Views:
    1,483
    Mike Treseler
    Jun 23, 2006
Loading...

Share This Page