Results 1 to 2 of 2

Thread: meaning of this for loop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70

    meaning of this for loop

    Hello
    can some one tell me the meaning of this for loop

    for (i=0;i<52;i++)
    deck[i]= 0| [i/13] | ((i%13) << 2 ) | (! (i/26) << 6 );

    i am not familiar with bit manipulations. so any help would be greatly appreciated.
    thanks
    radhika

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    ok it is creating an array with with the loop going from 0 to 52

    and putting thta equation into english

    deck[i]= 0 Or [i divided by 13] Or ((i Modulus 13) shift left 2 bits ) Or (not (i divided by 26) shift left 6 bit )

    modulus in case you dont know returns the remander after dividing those 2 numbers.

    even in plain english that is still pretty confusing..

    now the brackets are 1/13 im not sure of. perhaps it converts to a byte..or something..Cant be certain. Im still learning all these operators myself.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width