Velocity Reviews > Algorithm newsgroup?

# Algorithm newsgroup?

Paminu
Guest
Posts: n/a

 10-05-2005
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.

Alexei A. Frounze
Guest
Posts: n/a

 10-05-2005
"Paminu" <(E-Mail Removed)> wrote in message
news:dhvurc\$pv3\$(E-Mail Removed)-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

Paminu
Guest
Posts: n/a

 10-05-2005
Alexei A. Frounze wrote:

> "Paminu" <(E-Mail Removed)> wrote in message
> news:dhvurc\$pv3\$(E-Mail Removed)-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?

pete
Guest
Posts: n/a

 10-05-2005
Paminu wrote:

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

That's undefined if UCHAR_MAX equals 0xffffu.

--
pete

pete
Guest
Posts: n/a

 10-05-2005
Paminu wrote:
>
> Alexei A. Frounze wrote:
>
> > "Paminu" <(E-Mail Removed)> wrote in message
> > news:dhvurc\$pv3\$(E-Mail Removed)-c.dk...
> >> Where do I find an algorithm newsgroup?

news:comp.programming

--
pete

Skarmander
Guest
Posts: n/a

 10-05-2005
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.

Alexei A. Frounze
Guest
Posts: n/a

 10-05-2005
"Paminu" <(E-Mail Removed)> wrote in message
news:di004u\$q85\$(E-Mail Removed)-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

pete
Guest
Posts: n/a

 10-05-2005
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

 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 senthil VHDL 3 11-25-2011 11:58 AM Bapaiah Katepalli VHDL 1 06-23-2006 04:50 PM Jason Coyne Gaijin42 ASP .Net 0 04-08-2004 07:26 PM Ahmed Moustafa Java 0 11-15-2003 06:35 AM Adam VHDL 5 11-08-2003 06:26 PM

Advertisments