• Challenge

    From Digital Man@VERT to All on Wednesday, June 21, 2006 13:16:51
    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

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Johnatuna@VERT/NEOPHYTE to Digital Man on Wednesday, June 21, 2006 16:30:00
    Re: Challenge
    InternetMailingDigital Man

    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....:)
    johnatuna
    Neophyte BBS Open 24/7 DoveNet/DarkNet Over 75 Gigs in Files! neophyte.synchro.net


    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Deuce@VERT/SYNCNIX to Digital Man on Wednesday, June 21, 2006 18:49:00
    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?

    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Digital Man@VERT to Deuce on Wednesday, June 21, 2006 18:11:49
    Re: Challenge
    By: Deuce to Digital Man on Wed Jun 21 2006 06:49 pm

    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?

    But of course. What else could it be? :-)

    digital man

    Snapple "Real Fact" #12:
    Emus and Kangaroos cannot walk backwards.
    Norco, CA WX: 82.2øF, 45% humidity, 5 mph E wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Deuce@VERT/SYNCNIX to Digital Man on Wednesday, June 21, 2006 20:49:00
    Re: Challenge
    By: Digital Man to Deuce on Wed Jun 21 2006 06:11 pm

    for(x=0; y!=0; x++)
    y=y&(y-1);

    Counts the number of bits set in y storing the result in x?

    But of course. What else could it be? :-)

    It *could* be:

    x=0;
    while(y=y&(y-1))
    x++;


    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Lord Time@VERT/TIME to Johnatuna on Wednesday, June 21, 2006 16:21:00
    In a reply from Johnatuna on 16:30 about Challenge

    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,

    ditto

    even stupid for the fact that people such as myself do not have a logical bone
    in their body....:)

    hmmmm

    Rob Starr
    Lord Time SysOp of
    Time Warp of the Future BBS
    ICQ # 11868133 or # 70398519
    Yahoo : lordtime2000 AIM : LordTime20000 MSN : Lord Time

    þ CMPQwk 1.42 16554 þ I'm as confused as a baby at a topless bar!

    ---
    þ Synchronet þ Time Warp of the Future BBS - Home of League 10 IBBS Games
  • From Tracker1@VERT/TRN to Digital Man on Wednesday, June 21, 2006 23:22:00
    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.. :/

    --
    Michael J. Ryan - tracker1(at)theroughnecks(dot)net - www.theroughnecks.net icq: 4935386 - AIM/AOL: azTracker1 - Y!: azTracker1 - MSN/Win: (email)

    ---
    þ Synchronet þ theroughnecks.net - you know you want it
  • From Digital Man@VERT to Tracker1 on Friday, June 23, 2006 01:00:53
    Re: Re: Challenge
    By: Tracker1 to Digital Man on Wed Jun 21 2006 11:22 pm

    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! :-)

    digital man

    Snapple "Real Fact" #3:
    Beavers can hold their breathe for 45 minutes under water.
    Norco, CA WX: 64.2øF, 69% humidity, 0 mph WNW wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Angus McLeod@VERT/ANJO to Digital Man on Friday, June 23, 2006 08:21:00
    Re: Re: Challenge
    By: Digital Man to Tracker1 on Fri Jun 23 2006 01:00:00

    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! :-)

    The y=y&(y-1) expression is nicely obscure. And it neatly avoids
    iterating over 0-bits as well.

    ---
    Playing: "The asphalt world" by "Suede" from the "Dog man star" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Deuce@VERT/SYNCNIX to Angus McLeod on Friday, June 23, 2006 11:04:00
    Re: Re: Challenge
    By: Angus McLeod to Digital Man on Fri Jun 23 2006 08:21 am

    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! :-)

    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);



    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Angus McLeod@VERT/ANJO to Deuce on Saturday, June 24, 2006 00:12:00
    Re: Re: Challenge
    By: Deuce to Angus McLeod on Fri Jun 23 2006 11:04:00

    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);

    I know that one better like this:

    x -= (x >> 1) & 0x55555555;
    x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
    return ((x + (x >> 4) & 0x0f0f0f0f) * 0x01010101) >> 24;

    which is essentially the same thing, but I prefer not to use additional variables if they can be avoided.

    ---
    Strange: With 10,231 tracks available from 795 albums
    by 399 artists, I'm currently not listening to anything!
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Johnatuna@VERT/NEOPHYTE to Digital Man on Saturday, June 24, 2006 06:16:00
    Re: Challenge
    InternetMailingDigital Man

    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


    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...:)
    johnatuna
    Neophyte BBS Open 24/7 DoveNet/DarkNet Over 75 Gigs in Files! neophyte.synchro.net


    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Ispyhumanfly@VERT to Johnatuna on Sunday, June 25, 2006 06:53:15
    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 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...:)

    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...

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Angus McLeod@VERT/ANJO to Ispyhumanfly on Sunday, June 25, 2006 00:53:00
    Re: Re: Challenge
    By: Ispyhumanfly to Johnatuna on Sun Jun 25 2006 06:53:00

    for(starting value, limit, incriment) {
    do something...
    }

    Loosely. This:

    for (f=fopen("file.ext","r");!feof(f);fgets(buf,sizeof(buf),f) {
    /* do something */
    }

    is still a functioning for() statement.
    ---
    Playing: "Lover lay down" by "Dave Matthews Band"
    from the "Under the table & dreaming" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Johnatuna@VERT/NEOPHYTE to Ispyhumanfly on Sunday, June 25, 2006 03:39:00
    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?
    johnatuna
    Neophyte BBS Open 24/7 DoveNet/DarkNet Over 75 Gigs in Files! neophyte.synchro.net


    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Finnigann@VERT/BNB to Johnatuna on Sunday, June 25, 2006 08:37:00
    With interpidation and the MAGIC of QWK Mail Johnatuna wrote to
    Ispyhumanfly <=-

    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?

    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.
    --- MultiMail/Win32 v0.46
    þ Synchronet þ Bits-N-Bytes - bnb.dtdns.net / bnb.synchro.net
  • From Johnatuna@VERT/NEOPHYTE to Finnigann on Sunday, June 25, 2006 09:29:00
    Re: Re: Challenge
    InternetMailingFinnigann

    With interpidation and the MAGIC of QWK Mail Johnatuna wrote to
    Ispyhumanfly <=-

    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.

    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 of the pointer thing?
    johnatuna
    Neophyte BBS Open 24/7 DoveNet/DarkNet Over 75 Gigs in Files! neophyte.synchro.net


    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Angus McLeod@VERT/ANJO to Johnatuna on Sunday, June 25, 2006 11:00:00
    Re: Re: Challenge
    By: Johnatuna to Ispyhumanfly on Sun Jun 25 2006 03:39:00

    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?

    The three parts of this for() statement are:

    x=0;
    Set x to zero before the loop begins.

    y!=0;
    Check y and confirm that it is != (not equal) to zero. If this
    condition fails, the loop terminates.

    x++;
    A programming shorthand meaning "incriment x after it's been used."
    This occurs after each execution of the loop body, before the
    end condition is re-checked. (There is also ++x; which incriments
    before use. In this case, before or after use makes no difference, but
    post-incriment -- rather than pre-incriment -- is customary.)

    The body of the loop contains

    y=y&(y-1);
    Assign to y "y=", the result of it's original value "y" bitwise-ANDed
    "&" with itself minus one "(y-1)".



    ---
    Playing: "Watercolours in the rain" by "Roxette"
    from the "Joyride" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Angus McLeod@VERT/ANJO to Finnigann on Sunday, June 25, 2006 11:15:00
    Re: Re: Challenge
    By: Finnigann to Johnatuna on Sun Jun 25 2006 08:37:00

    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.

    Not in this case.

    X is a varible (it can be anything). That value is stored in a place in
    memory. &X is the address of that place.

    A clear enough description/explanation of pointers. But in this case, the
    "&" is a bitwise-AND operator.

    "y" is bitwise-ANDed with "itself-less-1" amd the result set back into "y".

    Say y contained the value 156 (binary = 10011100). Then (y-1) would be
    155 (binary = 10011011) and to perform the bitwuse AND we would do:

    y = 156 = 10011100
    (y-1) = 155 = 10011011
    y = y&(y-1) = 152 = 10011000
    ^ ^^ <-- a bit is set in the result only where
    a bit is present in both the first AND second operand to the bitwise-AND operator.

    This statement (y=y&(y-1) eliminates the Least Significant Bit of y rather cleverly, leaving all the other bits unchanged.
    ---
    Playing: "Perfect day" by "Roxette" from the "Joyride" album

    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Angus McLeod@VERT/ANJO to Johnatuna on Sunday, June 25, 2006 11:50:00
    Re: Re: Challenge
    By: Johnatuna to Finnigann on Sun Jun 25 2006 09:29:00

    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?

    The example for() loop is in C/C++. Similar code works in other
    languages, too. So the loop becomes:

    for ($x=0; $y!=0; $x++) {
    $y=$y&($y-1);
    }

    in Perl. (Perl uses a buck '$' to indicate a scalar variable, whereas
    C/C++ does not. '$x' in Perl means 'x' in C/C++. Also, Perl *requires*
    that you enclose the body of the loop in braces {}. C/C++ encloses the
    body of a loop in braces too, but only if the body consists of more than a single statement*. Since y=y&(y-1); is a single statement, the C/C++
    version does not require the {}.)

    *Ok, not technically correct, but for all practical purposes...

    ---
    Playing: "Bennie and The Jets" by "Elton John"
    from the "Goodbye yellow brick road" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Stormer@VERT/STORMERS to Johnatuna on Sunday, June 25, 2006 10:59:00
    Re: Re: Challenge
    By: Johnatuna to Ispyhumanfly on Sun Jun 25 2006 03:39 am

    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


    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

    Stormer

    ---
    þ Synchronet þ Stormer's Haven BBS : stormerlabs.homelinux.net
  • From Screwball@VERT/B1F4N0 to Ispyhumanfly on Monday, June 26, 2006 05:48:00
    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
    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...:)

    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?) ;)

    ---
    þ Synchronet þ B1F4N0 - shadowsoft.servebbs.com
  • From Angus McLeod@VERT/ANJO to Screwball on Monday, June 26, 2006 10:18:00
    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.



    ---
    Playing: "Stone woman" by "Bryan Ferry" from the "Boys & girls" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Digital Man@VERT to Johnatuna on Monday, June 26, 2006 14:06:57
    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 no 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

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Digital Man@VERT to Finnigann on Monday, June 26, 2006 14:09:59
    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 to
    Ispyhumanfly <=-

    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.

    digital man

    Snapple "Real Fact" #70:
    A "jiffy" is actually 1/100 of a second.
    Norco, CA WX: 102.0øF, 30% humidity, 2 mph WNW wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Stormer@VERT/STORMERS to Screwball on Monday, June 26, 2006 13:28:00
    Re: Re: Challenge
    By: Screwball to Ispyhumanfly on Mon Jun 26 2006 05:48 am

    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
    but
    noone has sat down with me to teach me. Funny, a 35 year old man who do
    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

    ---
    þ Synchronet þ Stormer's Haven BBS : stormerlabs.homelinux.net
  • From Finnigann@VERT/BNB to Digital Man on Monday, June 26, 2006 19:45:00
    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 to
    Ispyhumanfly <=-

    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.


    My cover is blown. I only took a semester of C++ programming. Got a 'B'

    http://www.kellogg.edu/infotech/cet/procertcore.html

    It's a goal...




    ----------------------------------------------------------------
    James King KC8UGV | Sysop - Bits-N-Bytes BBS
    Coldwater, MI 49036 | http://www.synchro.net/sbbslist.html
    ----------------------------------------------------------------
    RSS http://tinyurl.com/zswzs
    ----------------------------------------------------------------
    ... I need someone really bad... are you really bad?
    --- MultiMail/Win32 v0.46
    þ Synchronet þ Bits-N-Bytes - bnb.dtdns.net / bnb.synchro.net
  • From Johnatuna@VERT/NEOPHYTE to Digital Man on Monday, June 26, 2006 17:32:00
    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 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



    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, I don't mean to cause problems.

    johnatuna
    Neophyte BBS Open 24/7 DoveNet/DarkNet Over 75 Gigs in Files! neophyte.synchro.net


    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Screwball@VERT/B1F4N0 to Stormer on Monday, June 26, 2006 21:13:00
    Re: Re: Challenge
    By: Screwball to Ispyhumanfly on Mon Jun 26 2006 05:48 am

    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
    but
    noone has sat down with me to teach me. Funny, a 35 year old man who
    do
    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

    ---
    Well, maybe not a perfect example. ;)

    ---
    þ Synchronet þ B1F4N0 - shadowsoft.servebbs.com
  • From Screwball@VERT/B1F4N0 to Angus McLeod on Monday, June 26, 2006 21:29:00
    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.

    I stand corrected, but do we have to get technical? ;)

    ---
    þ Synchronet þ B1F4N0 - shadowsoft.servebbs.com
  • From Digital Man@VERT to Johnatuna on Monday, June 26, 2006 23:37:58
    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 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.

    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 F or below.
    Norco, CA WX: 76.8øF, 50% humidity, 0 mph W wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Angus McLeod@VERT/ANJO to Stormer on Tuesday, June 27, 2006 02:44:00
    Re: Re: Challenge
    By: Stormer to Screwball on Mon Jun 26 2006 13:28:00

    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.

    You don't *have* to do an incriment or decriment. Of course, you *can* incriment or decriment a counter, and many times, that's what programmers
    do because that's what they need. But you can do virtually ANYTHING.

    ---
    Playing: "Breaking the silence" by "Queensryche"
    from the "Operation" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Angus McLeod@VERT/ANJO to Screwball on Tuesday, June 27, 2006 02:51:00
    Re: Re: Challenge
    By: Screwball to Angus McLeod on Mon Jun 26 2006 21:29:00

    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? ;)

    I wasn't trying to be argumentative, but that little code-fragment that DM posted recently has prompted various reactions. Looking at various
    fragments of the, uh, fragment, some people have oversimplifed and some
    people have overcomplicated.


    ---
    Playing: "My empty room" by "Queensryche" from the "Operation" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Johnatuna@VERT/NEOPHYTE to Digital Man on Tuesday, June 27, 2006 04:01:00
    Re: Challenge
    InternetMailingDigital Man

    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




    Sorry about that post...yesterday was a day from hell for me. I had to
    present a paper that was not ready. I'm in a classroom full of graduate students a hell of a lot smarter than I am and every class I leave feeling
    like the stupidist son-of-a-bitch that ever lived. Until this point in my college career, I have been given help to get through my classes. Being learning disabled, and legally blind makes college a pain in the ass when you have no help. So yesterday's posting should not have been posted...sorry
    about that. I just hope I didn't post any messages anyway making anyone
    angry.

    johnatuna
    Neophyte BBS Open 24/7 DoveNet/DarkNet Over 75 Gigs in Files! neophyte.synchro.net


    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Deuce@VERT/SYNCNIX to Stormer on Tuesday, June 27, 2006 12:01:00
    Re: Re: Challenge
    By: Stormer to Johnatuna on Sun Jun 25 2006 10:59 am

    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 even more fun the first line could bE:
    for(x=0;y;x++)


    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Angus McLeod@VERT/ANJO to Deuce on Tuesday, June 27, 2006 15:26:00
    Re: Re: Challenge
    By: Deuce to Stormer on Tue Jun 27 2006 12:01:00

    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++)

    and the second line could be

    y&=y-1;

    You could even code the entire thing as

    for (x=1;y&=y-1;x++)
    ;

    if you knew that there was at least ONE bit set...

    ;-)
    ---
    Playing: "Unravelling" by "Weedpuller" from the "Girth" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Deuce@VERT/SYNCNIX to Angus McLeod on Tuesday, June 27, 2006 14:33:00
    Re: Re: Challenge
    By: Angus McLeod to Deuce on Tue Jun 27 2006 03:26 pm

    Re: Re: Challenge
    By: Deuce to Stormer on Tue Jun 27 2006 12:01:00

    for(x=0; y!=0; x++)
    y=y&(y-1);
    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;


    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Angus McLeod@VERT/ANJO to Deuce on Wednesday, June 28, 2006 00:02:00
    Re: Re: Challenge
    By: Deuce to Angus McLeod on Tue Jun 27 2006 14:33:00

    for(x=0; y!=0; x++)
    y=y&(y-1);

    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.
    ---
    Playing: "Politik" by "Coldplay" from the "Live 2003" album

    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Deuce@VERT/SYNCNIX to Angus McLeod on Wednesday, June 28, 2006 10:24:00
    Re: Re: Challenge
    By: Angus McLeod to Deuce on Wed Jun 28 2006 12:02 am

    for(x=0; y!=0; x++)
    y=y&(y-1);

    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.

    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 operator in the same statement?

    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Angus McLeod@VERT/ANJO to Deuce on Wednesday, June 28, 2006 19:38:00
    Re: Re: Challenge
    By: Deuce to Angus McLeod on Wed Jun 28 2006 10:24:00

    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++);

    I *like* this one!

    and
    if(y)for(x=1;y&=y-1;x++);

    No, not so keen on this one! :-)

    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.

    ---
    Playing: "Big romantic stuff" by "Bob Geldof"
    from "The vegitarians of love" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Deuce@VERT/SYNCNIX to Angus McLeod on Thursday, June 29, 2006 00:26:00
    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 formulated as:

    for(bits=0; val; bits++)
    val&=val-1; /* Clear least significant bit */


    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Digital Man@VERT to Deuce on Thursday, June 29, 2006 13:05:39
    Re: Re: Challenge
    By: Deuce to Angus McLeod on Thu Jun 29 2006 12:26 am

    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 */

    Or even the brute-force, least efficient, but most readable:

    for(i=0, bits=0; i<sizeof(val)*8; i++)
    if(val&(1<<i))
    bits++;

    That's how *I* answered the interview question some 5+ years ago. <shrug>

    digital man

    Snapple "Real Fact" #85:
    The Mona Lisa has no eyebrows.
    Norco, CA WX: 101.3øF, 28% humidity, 3 mph NNE wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Tracker1@VERT/TRN to Digital Man on Monday, July 03, 2006 01:43:00
    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)

    ---
    þ Synchronet þ theroughnecks.net - you know you want it
  • From Tracker1@VERT/TRN to Deuce on Monday, July 03, 2006 01:45:00
    Deuce wrote:
    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.

    --
    Michael J. Ryan - tracker1(at)theroughnecks(dot)net - www.theroughnecks.net icq: 4935386 - AIM/AOL: azTracker1 - Y!: azTracker1 - MSN/Win: (email)

    ---
    þ Synchronet þ theroughnecks.net - you know you want it
  • From Angus McLeod@VERT/ANJO to Tracker1 on Monday, July 03, 2006 10:44:00
    Re: Re: Challenge
    By: Tracker1 to Digital Man on Mon Jul 03 2006 01:43:00

    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?

    Maybe

    for(t=y, x=0; t; x++)
    t&=t-1;

    would work? (But there's that comma again...)

    ---
    Playing: "Seeds of a Smaller World" by "Weedpuller"
    from the "Congenital" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Digital Man@VERT to Tracker1 on Monday, July 03, 2006 10:46:35
    Re: Re: Challenge
    By: Tracker1 to Digital Man on Mon Jul 03 2006 01:43 am

    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?

    v=y; // preserve value in 'y'
    for(x=0; v!=0; x++)
    v=v&(v-1);

    digital man

    Snapple "Real Fact" #88:
    A ten gallon hat holds less then one gallon of liquid.
    Norco, CA WX: 98.0øF, 33% humidity, 0 mph NE wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Johnatuna@VERT/NEOPHYTE to Tracker1 on Monday, July 03, 2006 12:02:00
    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?

    --
    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!

    johnatuna

    Neophyte BBS Open 24/7
    Over 75 Gigs in Files! DoveNet/DarkNet/StarNet/Ilink
    neophyte.synchro.net

    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Death@VERT/DARKNESS to Johnatuna on Monday, July 03, 2006 15:41:00

    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

    Dude, no one on this network jumps your ass for wanting to learn..
    Maybe for wanted the information "handed" to you, with you doing no
    work of your own.. But don't worry, no "ass jumping" happens here,
    unless someone deserves it. =o)

    Death



    Home of DarkNet



    ---
    þ Synchronet þ Darkness BBS - darkness.synchro.net
  • From Digital Man@VERT to Johnatuna on Monday, July 03, 2006 12:51:18
    Re: Re: Challenge
    By: Johnatuna to Tracker1 on Mon Jul 03 2006 12:02 pm

    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

    In this context, '&' represents a bit-wise "AND" operation (nothing to do with pointers).

    If you take a binary number, like say, 0101101, and you "AND" it with another number, say, 1001001, the result is a value containing the bits "set" (to 1) in both numbers. i.e.

    0101101
    & 1001001
    -------
    = 0001001

    The other bit-wise operations are "OR" (represented in C with the '|' symbol), "XOR" ('^' in C), and "NOT" ('~' in C). An "OR" operation results in a value with bits "set" in *either* number, i.e.

    0101101
    | 1001001
    -------
    = 1101101

    An "XOR" operation results in a value with "set" bits only in positions where the 2 source numbers contain a different bit value (0 where they're the same). i.e.

    0101101
    ^ 1001001
    -------
    = 1100100

    A "NOT" operation takes a single operand (value to operate on) and results in a value with the inverse-bits set:

    ~ 0101101
    -------
    = 1010010

    These are the bit-wise operators common to most programming language, although the syntax and use may differ a bit, the logic and results are the same.

    digital man

    Snapple "Real Fact" #17:
    A hummingbird weighs less then a penny.
    Norco, CA WX: 97.7øF, 32% humidity, 7 mph WSW wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Deuce@VERT/SYNCNIX to Tracker1 on Tuesday, July 04, 2006 11:03:00
    Re: Re: Challenge
    By: Tracker1 to Digital Man on Mon Jul 03 2006 01:43 am

    hmmm... what if you wanted to preserve y?

    Store it first.

    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Deuce@VERT/SYNCNIX to Tracker1 on Tuesday, July 04, 2006 11:04:00
    Re: Re: Challenge
    By: Tracker1 to Deuce on Mon Jul 03 2006 01:45 am

    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.

    Goodness, I didn't write that. It's in the Giant Lib of Usefull Functions.

    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Christopher Perrault@VERT/DMINE to Johnatuna on Saturday, August 05, 2006 18:51:00
    Re: Re: Challenge
    By: Johnatuna to Finnigann on Sun Jun 25 2006 10:29 am

    The exercise was a bit over my head, but in this case I think the '&' was used as a bitwise operator(as opposed to logical). I won't try to explain bitwise operators since, well, I can't LOL.

    I kind of know what they are but haven't toyed with them enough to understand them that well. I'm sure there are others who will have a better explanation.

    The '&' is also used with a variable name when it is used as a reference variable which is similar to a pointer. It's been a while since I touched that one too<grin>.


    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?

    C++ is the first one I would look at in this case. Specifically the parts on operators and loops. /////////////////////////////////////////////////////////////////////////////// /////// Chris Perrault ////////// ////// THE DIAMOND MINE BBS ////////// ///// Telnet bbs.dmine.net ////////// ///////////////////////////////////////////////////////////////////////////

    ---
    þ Synchronet þ Diamond Mine Online BBS - bbs.dmine.net
  • From Christopher Perrault@VERT/DMINE to Death on Sunday, August 06, 2006 19:14:00
    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 ////////// ///////////////////////////////////////////////////////////////////////////

    ---
    þ Synchronet þ Diamond Mine Online BBS - bbs.dmine.net
  • From Johnatuna@VERT/NEOPHYTE to Christopher Perrault on Monday, August 07, 2006 01:46:00
    Re: Re: Challenge
    InternetMailingChristopher Perrault

    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


    ---
    þ Synchronet þ Neophyte BBS - neophyte.synchro.net
  • From Christopher Perrault@VERT/DMINE to Johnatuna on Monday, August 07, 2006 21:13:00
    Re: Re: Challenge
    By: Johnatuna to Christopher Perrault on Mon Aug 07 2006 02:46 am

    Oooohh,, that sounds painfull<grin>. I'm sure hitting a gasline will be a real trip. LOL
    /s

    Backhoe digging while on LSD...:)

    johnatuna

    Neophyte BBS
    DoveNet/DarkNet/StarNet/Ilink
    telnet: neophyte.synchro.net


    /////////////////////////////////////////////////////////////////////////////// /////// Chris Perrault ////////// ////// THE DIAMOND MINE BBS ////////// ///// Telnet bbs.dmine.net ////////// ///////////////////////////////////////////////////////////////////////////

    ---
    þ Synchronet þ Diamond Mine Online BBS - bbs.dmine.net