What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
digital man
Snapple "Real Fact" #31:
The average human will eat an average of 8 spiders while sleeping.
Norco, CA WX: 93.7øF, 38% humidity, 4 mph WSW wind, 0.00 inches rain/24hrs
for(x=0; y!=0; x++)
y=y&(y-1);
Re: Challenge
By: Digital Man to All on Wed Jun 21 2006 01:16 pm
for(x=0; y!=0; x++)
y=y&(y-1);
Counts the number of bits set in y storing the result in x?
y=y&(y-1);for(x=0; y!=0; x++)
Counts the number of bits set in y storing the result in x?
But of course. What else could it be? :-)
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
digital man
Snapple "Real Fact" #31:
The average human will eat an average of 8 spiders while sleeping.
Norco, CA WX: 93.7øF, 38% humidity, 4 mph WSW wind, 0.00 inches rain/24hrs
The purpose of this algorithm is to make people such as myself feel inferior,
even stupid for the fact that people such as myself do not have a logical bone
in their body....:)
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
Digital Man wrote:
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
sounds like someone that doesn't know how to use a sleep call.. :/
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
sounds like someone that doesn't know how to use a sleep call.. :/
Nope. Deuce got it right. I should've exempted him! :-)
What is the purpose of the following algorithm:
y=y&(y-1);for(x=0; y!=0; x++)
sounds like someone that doesn't know how to use a sleep call.. :/
Nope. Deuce got it right. I should've exempted him! :-)
The y=y&(y-1) expression is nicely obscure. And it neatly avoids
iterating over 0-bits as well.
The y=y&(y-1) expression is nicely obscure. And it neatly avoids iterating over 0-bits as well.
Not as obscure or efficient (on average) as:
unsigned int const w = v - ((v >> 1) & 0x55555555);
unsigned int const x = (w & 0x33333333) + ((w >> 2) & 0x33333333);
unsigned int const c = ((x + (x >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; return(c);
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
digital man
Snapple "Real Fact" #31:
The average human will eat an average of 8 spiders while sleeping.
Norco, CA WX: 93.7øF, 38% humidity, 4 mph WSW wind, 0.00 inches rain/24hrs
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math but noone has sat down with me to teach me. Funny, a 35 year old man who does not know how to do math...what a damn shame...:)
for(starting value, limit, incriment) {
do something...
}
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math bu noone has sat down with me to teach me. Funny, a 35 year old man who does know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
}
--
ispyhumanfly +o euphoriabbs.net :: send comments to /dev/null...
With interpidation and the MAGIC of QWK Mail Johnatuna wrote toIspyhumanfly <=-
Re: Re: Challenge
InternetMailingIspyhumanfly
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math bu noone has sat down with me to teach me. Funny, a 35 year old man who does know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
}
--
ispyhumanfly +o euphoriabbs.net :: send comments to /dev/null...
I'm gong to get something out of this, so here it goes. X = 0..I understand Y! I do not understand...what does the ! mean? Also explain what X++ and y& means please. This looks interesting and I'd like to learn. One would have to say this is a algebraic math atleast. Does not algebra deal with situational math?
With interpidation and the MAGIC of QWK Mail Johnatuna wrote toIspyhumanfly <=-
Re: Re: Challenge
InternetMailingIspyhumanfly
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math noone has sat down with me to teach me. Funny, a 35 year old man who do know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
}
--
ispyhumanfly +o euphoriabbs.net :: send comments to /dev/null...
I'm gong to get something out of this, so here it goes. X = 0..I understand Y! I do not understand...what does the ! mean? Also explain what X++ and y& means please. This looks interesting and I'd like to learn. One would have to say this is a algebraic math atleast. Does not algebra deal with situational math?
Y! (why not) ! means not /me !happy /me != happy
& is harder to grasp (at least for me) is a pointer.
X is a varible (it can be anything). That value is stored in a place in
memory. &X is the address of that place.
Someone else MAY say it better.
----------------------------------------------------------------
James King KC8UGV | Sysop - Bits-N-Bytes BBS
Coldwater, MI 49036 | http://www.synchro.net/sbbslist.html
----------------------------------------------------------------
RSS http://tinyurl.com/zswzs
----------------------------------------------------------------
... WANTED: Man to work in dynamite factory. Must be willing to travel.
for(x=0; y!=0; x++)
y=y&(y-1);
I'm gong to get something out of this, so here it goes. X = 0..I understand I do not understand...what does the ! mean? Also explain what X++ and y& mea please. This looks interesting and I'd like to learn.
One would have to say this is a algebraic math atleast. Does not algebra dea with situational math?
for(x=0; y!=0; x++)
y=y&(y-1);
I'm gong to get something out of this, so here it goes. X = 0..I understand Y! I do not understand...what does the ! mean? Also explain what X++ and y& means please. This looks interesting and I'd like to learn. One would have to say this is a algebraic math atleast. Does not algebra deal with situational math?
& is harder to grasp (at least for me) is a pointer.
X is a varible (it can be anything). That value is stored in a place in
memory. &X is the address of that place.
for(x=0; y!=0; x++)
y=y&(y-1);
Y! (why not) ! means not /me !happy /me != happy
& is harder to grasp (at least for me) is a pointer.
X is a varible (it can be anything). That value is stored in a place in
memory. &X is the address of that place.
Everything you just said, I understood...except for the pointer thing...hehehe...:)
Is this a particular language that I can read about to gain an understanding the pointer thing?
Re: Re: Challenge
InternetMailingIspyhumanfly
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math noone has sat down with me to teach me. Funny, a 35 year old man who do know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
}
--
ispyhumanfly +o euphoriabbs.net :: send comments to /dev/null...
I'm gong to get something out of this, so here it goes. X = 0..I understand I do not understand...what does the ! mean? Also explain what X++ and y& mea please. This looks interesting and I'd like to learn.
One would have to say this is a algebraic math atleast. Does not algebra dea with situational math?
johnatuna
Neophyte BBS Open 24/7 DoveNet/DarkNet Over 75 Gigs in Files! neophyte.synchro.net
Johnatuna wrote:but
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math
noone has sat down with me to teach me. Funny, a 35 year old man who doesnot
know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
for(starting value, limit, incriment) {
do something...
Okay, how do you increment a variable without Adding? (is this not Math?) ;)
Re: Challenge
InternetMailingDigital Man
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this?
Calculus? I have always wanted to learn math but
noone has sat down with me to teach me. Funny, a 35 year old man who does no know how to do math...what a damn shame...:)
With interpidation and the MAGIC of QWK Mail Johnatuna wrote toIspyhumanfly <=-
Re: Re: Challenge
InternetMailingIspyhumanfly
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math noone has sat down with me to teach me. Funny, a 35 year old man who do know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
}
--
ispyhumanfly +o euphoriabbs.net :: send comments to /dev/null...
I'm gong to get something out of this, so here it goes. X = 0..I understand Y! I do not understand...what does the ! mean? Also explain what X++ and y& means please. This looks interesting and I'd like to learn. One would have to say this is a algebraic math atleast. Does not algebra deal with situational math?
Y! (why not) ! means not /me !happy /me != happy
& is harder to grasp (at least for me) is a pointer.
X is a varible (it can be anything). That value is stored in a place in
memory. &X is the address of that place.
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
butWhat kind of math is this? Calculus? I have always wanted to learn math
noone has sat down with me to teach me. Funny, a 35 year old man who donot
know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
Okay, how do you increment a variable without Adding? (is this not Math?) ;)
With interpidation and the MAGIC of QWK Mail Digital Man wrote to Finnigann<=-
Re: Re: Challenge
By: Finnigann to Johnatuna on Sun Jun 25 2006 08:37 am
With interpidation and the MAGIC of QWK Mail Johnatuna wrote toIspyhumanfly <=-
Re: Re: Challenge
InternetMailingIspyhumanfly
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this? Calculus? I have always wanted to learn math noone has sat down with me to teach me. Funny, a 35 year old man who do know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
}
--
ispyhumanfly +o euphoriabbs.net :: send comments to /dev/null...
I'm gong to get something out of this, so here it goes. X = 0..I understand Y! I do not understand...what does the ! mean? Also explain what X++ and y& means please. This looks interesting and I'd like to learn. One would have to say this is a algebraic math atleast. Does not algebra deal with situational math?
Y! (why not) ! means not /me !happy /me != happy
& is harder to grasp (at least for me) is a pointer.
In this context, & is a bit-wise "AND". It has nothing to do with
pointers or addresses.
X is a varible (it can be anything). That value is stored in a place in
memory. &X is the address of that place.
If "&x" were used in the expression, that would be true, but it's not.
Re: Challenge
By: Johnatuna to Digital Man on Sat Jun 24 2006 06:16 am
Re: Challenge
InternetMailingDigital Man
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this?
It's C programming... you know.. Progamming... the name of this message area :-)
Calculus? I have always wanted to learn math but
noone has sat down with me to teach me. Funny, a 35 year old man who does know how to do math...what a damn shame...:)
I never learned calculus either. <shrug>
digital man
Snapple "Real Fact" #25:
The only food that does not spoil is honey.
Norco, CA WX: 102.0øF, 30% humidity, 2 mph WNW wind, 0.00 inches rain/24hrs
Re: Re: ChallengeWell, maybe not a perfect example. ;)
By: Screwball to Ispyhumanfly on Mon Jun 26 2006 05:48 am
Johnatuna wrote:
for(x=0; y!=0; x++)
y=y&(y-1);
mathWhat kind of math is this? Calculus? I have always wanted to learn
butdo
noone has sat down with me to teach me. Funny, a 35 year old man who
not
know how to do math...what a damn shame...:)
this isn't math, this is a for loop...
for(starting value, limit, incriment) {
do something...
Okay, how do you increment a variable without Adding? (is this not Math?);)
Actually, if a for loop you can also decrement (decrease something). A shuttle
launch or microwave timer is a perfect example of this. (5..4..3..2..1..ding!). You'd express a decrement shorthand as x-- , for example.
Stormer
---
Re: Re: Challenge
By: Screwball to Ispyhumanfly on Mon Jun 26 2006 05:48:00
for(starting value, limit, incriment) {
do something...
Okay, how do you increment a variable without Adding? (is this not Math?);)
Technically, it would be simple arithmetic.
Not higher mathematics.
Re: Challenge
InternetMailingDigital Man
Re: Challenge
By: Johnatuna to Digital Man on Sat Jun 24 2006 06:16 am
Re: Challenge
InternetMailingDigital Man
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this?
It's C programming... you know.. Progamming... the name of this message a :-)
Calculus? I have always wanted to learn math but
noone has sat down with me to teach me. Funny, a 35 year old man who d know how to do math...what a damn shame...:)
I never learned calculus either. <shrug>
I know this is a programming area...duh...:)
But that did look like math. I once learned programming but have not done it in years....I sucked because I did not know math.
I pretty much suck at everything in life, so please bare with my ignorance, don't mean to cause problems.
Actually, if a for loop you can also decrement (decrease something). A shut launch or microwave timer is a perfect example of this. (5..4..3..2..1..ding!). You'd express a decrement shorthand as x-- , for example.
for(starting value, limit, incriment) {
do something...
Okay, how do you increment a variable without Adding? (is this not Mat
Technically, it would be simple arithmetic.
Not higher mathematics.
I stand corrected, but do we have to get technical? ;)
Re: Challenge
By: Johnatuna to Digital Man on Mon Jun 26 2006 05:32 pm
Re: Challenge
InternetMailingDigital Man
Re: Challenge
By: Johnatuna to Digital Man on Sat Jun 24 2006 06:16 am
Re: Challenge
InternetMailingDigital Man
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
What kind of math is this?
It's C programming... you know.. Progamming... the name of this messag :-)
Calculus? I have always wanted to learn math but
noone has sat down with me to teach me. Funny, a 35 year old man wh know how to do math...what a damn shame...:)
I never learned calculus either. <shrug>
I know this is a programming area...duh...:)
But that did look like math. I once learned programming but have not done in years....I sucked because I did not know math.
I pretty much suck at everything in life, so please bare with my ignoranc don't mean to cause problems.
No problem. I was just giving you a good-natured "hard time". Don't sweat it :-)
digital man
Snapple "Real Fact" #142:
Hawaii is the only U.S. state never to report a temperature of zero degrees Norco, CA WX: 76.8øF, 50% humidity, 0 mph W wind, 0.00 inches rain/24hrs
for(x=0; y!=0; x++)
y=y&(y-1);
When you see an expression like y!=0, what you should read is y does not equal zero. The ! is used to say 'not'.
x++ is shorthand for x = x + 1, which increments x, for example (0, 1, 2, 3 ...). The ampersand? Got me right now. I'd have to go look it up. :P
for(x=0; y!=0; x++)
y=y&(y-1);
When you see an expression like y!=0, what you should read is y does not equal zero. The ! is used to say 'not'.
x++ is shorthand for x = x + 1, which increments x, for example (0, 1, 2, ...). The ampersand? Got me right now. I'd have to go look it up. :P
For even more fun the first line could bE:
for(x=0;y;x++)
Re: Re: Challenge
By: Deuce to Stormer on Tue Jun 27 2006 12:01:00
y=y&(y-1);for(x=0; y!=0; x++)
for (x=1;y&=y-1;x++)
;
if you knew that there was at least ONE bit set...
y=y&(y-1);for(x=0; y!=0; x++)
for (x=1;y&=y-1;x++)
;
if you knew that there was at least ONE bit set...
You mean:
x=y?(({for(x=1;y&=y-1;x++);}),x):0;
y=y&(y-1);for(x=0; y!=0; x++)
;for (x=1;y&=y-1;x++)
if you knew that there was at least ONE bit set...
You mean:
x=y?(({for(x=1;y&=y-1;x++);}),x):0;
Well, yes, but your new solution is actually longer than the original proposal, before even we began to reduce it with s few simplifications.
You mean:
x=y?(({for(x=1;y&=y-1;x++);}),x):0;
Well, yes, but your new solution is actually longer than the original proposal, before even we began to reduce it with s few simplifications.
Well, any test for y!=0 will result in more code any way I slice it... even: for(x=y?1:0;y&=y-1;x++);
and
if(y)for(x=1;y&=y-1;x++);
But how can you turn away from an excuse to use braces and the comma operato in the same statement?
But how can you turn away from an excuse to use braces and the comma operato in the same statement?
Because I don't like the comma operator. Sure I use it when called for,
but I'd prefer a solution that doesn't use it.
Re: Re: Challenge
By: Angus McLeod to Deuce on Wed Jun 28 2006 07:38 pm
But how can you turn away from an excuse to use braces and the comma operato in the same statement?
Because I don't like the comma operator. Sure I use it when called for, but I'd prefer a solution that doesn't use it.
Well, if we're talking in real life, it would be more likely to be formulate as:
for(bits=0; val; bits++)
val&=val-1; /* Clear least significant bit */
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
sounds like someone that doesn't know how to use a sleep call.. :/
Nope. Deuce got it right. I should've exempted him! :-)
Not as obscure or efficient (on average) as:
unsigned int const w = v - ((v >> 1) & 0x55555555);
unsigned int const x = (w & 0x33333333) + ((w >> 2) & 0x33333333);
unsigned int const c = ((x + (x >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; return(c);
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
sounds like someone that doesn't know how to use a sleep call.. :/
Nope. Deuce got it right. I should've exempted him! :-)
hmmm... what if you wanted to preserve y?
Digital Man wrote:
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
sounds like someone that doesn't know how to use a sleep call.. :/
Nope. Deuce got it right. I should've exempted him! :-)
hmmm... what if you wanted to preserve y?
Digital Man wrote:
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
sounds like someone that doesn't know how to use a sleep call.. :/
Nope. Deuce got it right. I should've exempted him! :-)
hmmm... what if you wanted to preserve y?
--
Michael J. Ryan - tracker1(at)theroughnecks(dot)net - www.theroughnecks.net icq: 4935386 - AIM/AOL: azTracker1 - Y!: azTracker1 - MSN/Win: (email)
With help, I came to understand this algoryth. Can anyone explain &. This represents pointer? Pointer to what?
Before anyone like DM jumps my ass, please remember....I am wanting to learn
Re: Re: Challenge
InternetMailingTracker1
Digital Man wrote:
What is the purpose of the following algorithm:
for(x=0; y!=0; x++)
y=y&(y-1);
sounds like someone that doesn't know how to use a sleep call.. :/
Nope. Deuce got it right. I should've exempted him! :-)
hmmm... what if you wanted to preserve y?
With help, I came to understand this algoryth. Can anyone explain &. This represents pointer? Pointer to what?
Before anyone like DM jumps my ass, please remember....I am wanting to learn
hmmm... what if you wanted to preserve y?
Not as obscure or efficient (on average) as:
unsigned int const w = v - ((v >> 1) & 0x55555555);
unsigned int const x = (w & 0x33333333) + ((w >> 2) & 0x33333333); unsigned int const c = ((x + (x >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; return(c);
/me thinks Deuce is *VERY* secure in his job.
Everything you just said, I understood...except for the pointer thing...hehehe...:)
Is this a particular language that I can read about to gain an understanding the pointer thing?
But don't worry, no "ass jumping" happens here,
unless someone deserves it. =o)
Death
Re: Re: Challenge
By: Death to Johnatuna on Mon Jul 03 2006 04:41 pm
Is there a new extreme sport I'm not aware of? :-)
/s
But don't worry, no "ass jumping" happens here,
unless someone deserves it. =o)
Death
//////////////////////////////////////////////////////////////////////////// /////// Chris Perrault //////// ////// THE DIAMOND MINE BBS ///////// ///// Telnet bbs.dmine.net ////////// ///////////////////////////////////////////////////////////////////////////
Backhoe digging while on LSD...:)
johnatuna
Neophyte BBS
DoveNet/DarkNet/StarNet/Ilink
telnet: neophyte.synchro.net
Sysop: | MCMLXXIX |
---|---|
Location: | Prospect, CT |
Users: | 333 |
Nodes: | 10 (0 / 10) |
Uptime: | 147:32:22 |
Calls: | 581 |
Messages: | 237925 |