what the meaning of this?

Discussion in 'C Programming' started by newbie, Mar 3, 2006.

  1. newbie

    newbie Guest

    anyone know is it this source code value:-
    T = ((Y >> 4) ^ X) & 0x0F0F0F0F; X ^= T; Y ^= (T << 4);

    T = ((Y ) ^ X) & 0x10101010; X ^= T; Y ^= (T );

    X = (LHs[ (X ) & 0xF] << 3) | (LHs[ (X >> 8) & 0xF ] << 2)
    | (LHs[ (X >> 16) & 0xF] << 1) | (LHs[ (X >> 24) & 0xF ] )
    | (LHs[ (X >> 5) & 0xF] << 7) | (LHs[ (X >> 13) & 0xF ] << 6)
    | (LHs[ (X >> 21) & 0xF] << 5) | (LHs[ (X >> 29) & 0xF ] << 4);

    Y = (RHs[ (Y >> 1) & 0xF] << 3) | (RHs[ (Y >> 9) & 0xF ] << 2)
    | (RHs[ (Y >> 17) & 0xF] << 1) | (RHs[ (Y >> 25) & 0xF ] )
    | (RHs[ (Y >> 4) & 0xF] << 7) | (RHs[ (Y >> 12) & 0xF ] << 6)
    | (RHs[ (Y >> 20) & 0xF] << 5) | (RHs[ (Y >> 28) & 0xF ] << 4);

    X &= 0x0FFFFFFF;
    Y &= 0x0FFFFFFF;

    same as the PC-1 table value?

    PC-1
    57 49 41 33 25 17 9
    1 58 50 42 34 26 18
    10 2 59 51 43 35 27
    19 11 3 60 52 44 36

    63 55 47 39 31 23 15
    7 62 54 46 38 30 22
    14 6 61 53 45 37 29
    21 13 5 28 20 12 4

    and how to compare both?
     
    newbie, Mar 3, 2006
    #1
    1. Advertising

  2. In article <>,
    newbie <> wrote:
    >anyone know is it this source code value:-
    > T = ((Y >> 4) ^ X) & 0x0F0F0F0F; X ^= T; Y ^= (T << 4);
    >
    > T = ((Y ) ^ X) & 0x10101010; X ^= T; Y ^= (T );
    >
    > X = (LHs[ (X ) & 0xF] << 3) | (LHs[ (X >> 8) & 0xF ] << 2)
    > | (LHs[ (X >> 16) & 0xF] << 1) | (LHs[ (X >> 24) & 0xF ] )


    You have not shown us the definition of LHs or RHs, so we cannot
    tell you what this expression produces.

    >same as the PC-1 table value?


    > PC-1
    > 57 49 41 33 25 17 9
    > 1 58 50 42 34 26 18
    > 10 2 59 51 43 35 27
    > 19 11 3 60 52 44 36
    >
    > 63 55 47 39 31 23 15
    > 7 62 54 46 38 30 22
    > 14 6 61 53 45 37 29
    > 21 13 5 28 20 12 4


    >and how to compare both?



    The code involves two input variables, X and Y, of at least 29
    bits, and calculates 3 values, T, X, and Y. T could plausibly be
    a temporary value, but the structure of the code shows that X and Y
    are both outputs.

    You ask that this output be compared to a single table, apparently
    of size 8 x 7, or perhaps 2 x 4 x 7, and whose values appear to be
    6 bits wide.

    Even if we interpret the empty line as indicating two output tables,
    one for X and the other for Y, we have a dimensionality clash:
    the output of an operation upon a 29+ bit value cannot be less than
    2^29th values [even if all the rest of them turn out to be 0]
    and a single variable of output cannot be compared to a 4 x 7 table
    of outputs without a mapping function... and no mapping function
    has been defined.

    Hence, no matter what the arithmetic produces, we can deduce
    that it does -not- produce the table we are asked to compare against.
    [Thus we do not need to analyze the bit-manipulation logic to produce
    the definite answer "NO".]
    --
    "law -- it's a commodity"
    -- Andrew Ryan (The Globe and Mail, 2005/11/26)
     
    Walter Roberson, Mar 3, 2006
    #2
    1. Advertising

  3. newbie

    newbie Guest

    the RH and LH as below:-

    static uint32 LHs[16] =
    {
    0x00000000, 0x00000001, 0x00000100, 0x00000101,
    0x00010000, 0x00010001, 0x00010100, 0x00010101,
    0x01000000, 0x01000001, 0x01000100, 0x01000101,
    0x01010000, 0x01010001, 0x01010100, 0x01010101
    };

    static uint32 RHs[16] =
    {
    0x00000000, 0x01000000, 0x00010000, 0x01010000,
    0x00000100, 0x01000100, 0x00010100, 0x01010100,
    0x00000001, 0x01000001, 0x00010001, 0x01010001,
    0x00000101, 0x01000101, 0x00010101, 0x01010101,
    };

    so what the expression produce?
     
    newbie, Mar 5, 2006
    #3
  4. newbie

    CBFalconer Guest

    newbie wrote:
    >
    > the RH and LH as below:-
    >
    > static uint32 LHs[16] =
    > {
    > 0x00000000, 0x00000001, 0x00000100, 0x00000101,
    > 0x00010000, 0x00010001, 0x00010100, 0x00010101,
    > 0x01000000, 0x01000001, 0x01000100, 0x01000101,
    > 0x01010000, 0x01010001, 0x01010100, 0x01010101
    > };
    >
    > static uint32 RHs[16] =
    > {
    > 0x00000000, 0x01000000, 0x00010000, 0x01010000,
    > 0x00000100, 0x01000100, 0x00010100, 0x01010100,
    > 0x00000001, 0x01000001, 0x00010001, 0x01010001,
    > 0x00000101, 0x01000101, 0x00010101, 0x01010101,
    > };
    >
    > so what the expression produce?


    Those are not expressions, they are initialization statements
    attached to a declaration. Who knows what they are intended to
    represent.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
    Also see <http://www.safalra.com/special/googlegroupsreply/>
     
    CBFalconer, Mar 5, 2006
    #4
  5. In article <>,
    newbie <> wrote:

    >the RH and LH as below:-


    Q: How do you tell that someone is using google groups as their
    newsreader?

    A: Look for the complete lack of quoting and attribution.


    >static uint32 LHs[16] =
    >{
    > 0x00000000, 0x00000001, 0x00000100, 0x00000101,


    >static uint32 RHs[16] =
    >{
    > 0x00000000, 0x01000000, 0x00010000, 0x01010000,


    >so what the expression produce?


    Which expression? As I pointed out before, the code obviously
    calculates *two* values, X and Y, not just *one* value.

    Your original question was, if I recall correctly, whether the
    code produced the same answer as the table of values you showed.
    [If I don't recall correctly, it's because you failed to quote
    appropriate context.]

    Examining the code and examining the table of values, without
    knowing what a "PC-1" is, and without figuring out exactly what the
    code calculates, we can determine that the code does not produce
    the given table of values -- not unless there are some unstated
    restrictions on the input values.

    To prove that the table values are not what the code produces, start
    with X and Y both 0. T is calculated in terms of shifts and XOR.
    Unsigned shifts never introduce binary 1's where there were none
    to start with, so the shifts are going to leave the values as 0.
    Similarily, XOR of 0 and 0 is 0, so the XOR is not going to
    introduce any new binary 1's. We can thus deduce that at the
    end of the introductory sequence, X, Y, and T will all be 0 when
    X and Y started at 0.

    Now look at the pair of long expressions. There are lookups and
    shifts and binary ORs. Again shifts and OR do not introduce new 1s
    out of 0's. But it is the looked-up values that are manipulated,
    so examine those. In each case, the array index used is a shift
    and AND of X or Y, and we know X and Y are 0 here, so in each
    case the array index used is going to be 0. And when we look
    at LHS[0] and RHS[0], we see 0's in both locations. From this
    we can deduce that when X and Y start out as 0, the final X and Y
    values are both going to come out as 0.

    If we know look at the PC-1 table of values given, then no matter
    how we mentally account for the mismatch in dimensions, we can see
    that none of the PC-1 values are ever 0. There is thus an output
    pair from the code that is not to be found in the PC-1 values,
    and hence the PC-1 values are not those produced by the code --
    at least to the limits of the documentation we are given about the
    input ranges.
    --
    Programming is what happens while you're busy making other plans.
     
    Walter Roberson, Mar 5, 2006
    #5
  6. newbie

    CBFalconer Guest

    Walter Roberson wrote:
    >

    .... snip ...
    >
    > Q: How do you tell that someone is using google groups as their
    > newsreader?
    >
    > A: Look for the complete lack of quoting and attribution.


    Most of the time just read the Organization: header in the
    article. If this says google, and the article is properly quoted,
    snipped, and not top-posted, you are fairly safe in assuming the
    writer to be an intelligent lifeform.

    At other times the user-agent: or X-newsreader: headers may be
    present and informative. Seeing these things involves viewing full
    headers or message source.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
    Also see <http://www.safalra.com/special/googlegroupsreply/>
     
    CBFalconer, Mar 5, 2006
    #6
  7. newbie

    Default User Guest

    CBFalconer wrote:

    > Walter Roberson wrote:
    > >

    > ... snip ...
    > >
    > > Q: How do you tell that someone is using google groups as their
    > > newsreader?
    > >
    > > A: Look for the complete lack of quoting and attribution.

    >
    > Most of the time just read the Organization: header in the
    > article. If this says google, and the article is properly quoted,
    > snipped, and not top-posted, you are fairly safe in assuming the
    > writer to be an intelligent lifeform.
    >
    > At other times the user-agent: or X-newsreader: headers may be
    > present and informative. Seeing these things involves viewing full
    > headers or message source.


    Or have a newsreader that allows you to customize the headers that are
    displayed. I added User-Agent to the usual From, Subject, and
    Newsgroups lines. That way, when I see G2/0.2 I know it's Google and
    can tailor my response as needed.


    Brian
     
    Default User, Mar 6, 2006
    #7
  8. In article <>,
    CBFalconer <> wrote:
    >Walter Roberson wrote:
    >> Q: How do you tell that someone is using google groups as their
    >> newsreader?


    >> A: Look for the complete lack of quoting and attribution.


    >At other times the user-agent: or X-newsreader: headers may be
    >present and informative. Seeing these things involves viewing full
    >headers or message source.


    The header fields are densely packed; it's a lot faster to notice the
    lack of quoting and attribution.

    Admittedly, the correlation is not 100%, but it has become so common
    these days that we are going to have to come up with a new
    expression to describe it, as it seems to me that we are
    now beyond the behaviour set implied by "The Endless September".
    How does "The Endless Google" ring?
    --
    I was very young in those days, but I was also rather dim.
    -- Christopher Priest
     
    Walter Roberson, Mar 6, 2006
    #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. Sander Odekerken

    Meaning of output value?

    Sander Odekerken, May 18, 2004, in forum: VHDL
    Replies:
    2
    Views:
    2,557
    John_H
    May 18, 2004
  2. Parthav
    Replies:
    4
    Views:
    2,039
    Mike Treseler
    Jan 13, 2006
  3. Frank

    Meaning of <%#

    Frank, Dec 30, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    591
  4. .NET Follower

    Meaning Of Timeout in FormsAuthentication???

    .NET Follower, Feb 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    384
    .NET Follower
    Feb 6, 2004
  5. Replies:
    4
    Views:
    814
Loading...

Share This Page