longer than long?

Discussion in 'iOS Development' started by kyle1320, Aug 1, 2010.

  1. kyle1320

    kyle1320 Banned

    Joined:
    Feb 5, 2009
    Messages:
    153
    Likes Received:
    0
    Device:
    2G iPod touch
    is there a 64 bit integer type that will work with cocoa touch? long long doesnt seem to work.
  2. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    I assumed that iOS is 32-bit only.
  3. kyle1320

    kyle1320 Banned

    Joined:
    Feb 5, 2009
    Messages:
    153
    Likes Received:
    0
    Device:
    2G iPod touch
    ohhhhh. i need more common sense

    Please Register or Log in to view images



    ok, i separated it into 2 parts
  4. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    as you seem to know, type long long is a 64 bit integer type on the iPhone. explain what you mean by "long long doesnt seem to work"

    That doesn't mean that you can't have data types wider than 32 bits.
  5. kyle1320

    kyle1320 Banned

    Joined:
    Feb 5, 2009
    Messages:
    153
    Likes Received:
    0
    Device:
    2G iPod touch
    it doesnt make any difference when i try to use more than 32 bits of data, i still get warnings when building.
  6. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    please post the problematic code.
  7. kyle1320

    kyle1320 Banned

    Joined:
    Feb 5, 2009
    Messages:
    153
    Likes Received:
    0
    Device:
    2G iPod touch
    already changed it, i separated the code into two 32-bit parts

    this is my first app, so im creating something fairly simple, a lights out app.

    i wanted to make an array so each light would turn on the other ones around it, but when i tried to make the array have more than 32 lines, it gave me warnings. it would build, but the last 4 lights would not do anything. (6x6 grid)

    basically, the code was

    Code:
    long long myButtonFunctions[1][36] = {
         {
            (1<<0)+(1<<1)+(1<<6),
            (1<<1)+(1<<0)+(1<<2)+(1<<7),
            (1<<2)+(1<<1)+(1<<3)+(1<<8),
            (1<<3)+(1<<2)+(1<<4)+(1<<9),
            (1<<4)+(1<<3)+(1<<5)+(1<<10),
            (1<<5)+(1<<4)+(1<<11),
            (1<<6)+(1<<0)+(1<<7)+(1<<12),
            (1<<7)+(1<<1)+(1<<6)+(1<<8)+(1<<13),
            (1<<8)+(1<<2)+(1<<7)+(1<<9)+(1<<14),
            (1<<9)+(1<<3)+(1<<8)+(1<<10)+(1<<15),
            (1<<10)+(1<<4)+(1<<9)+(1<<11)+(1<<16),
            (1<<11)+(1<<5)+(1<<10)+(1<<17),
            (1<<12)+(1<<6)+(1<<13)+(1<<18),
            (1<<13)+(1<<7)+(1<<12)+(1<<14)+(1<<19),
            (1<<14)+(1<<8)+(1<<13)+(1<<15)+(1<<20),
            (1<<15)+(1<<9)+(1<<14)+(1<<16)+(1<<21),
            (1<<16)+(1<<10)+(1<<15)+(1<<17)+(1<<22),
            (1<<17)+(1<<11)+(1<<16)+(1<<23),
            (1<<18)+(1<<12)+(1<<19)+(1<<24),
            (1<<19)+(1<<13)+(1<<18)+(1<<20)+(1<<25),
            (1<<20)+(1<<14)+(1<<19)+(1<<21)+(1<<26),
            (1<<21)+(1<<15)+(1<<20)+(1<<22)+(1<<27),
            (1<<22)+(1<<16)+(1<<21)+(1<<23)+(1<<28),
            (1<<23)+(1<<17)+(1<<22)+(1<<29),
            (1<<24)+(1<<18)+(1<<25)+(1<<30),
            (1<<25)+(1<<19)+(1<<24)+(1<<26)+(1<<31),
            (1<<26)+(1<<20)+(1<<25)+(1<<27)+(1<<32),
            (1<<27)+(1<<21)+(1<<26)+(1<<28)+(1<<33),
            (1<<28)+(1<<22)+(1<<27)+(1<<29)+(1<<34),
            (1<<29)+(1<<23)+(1<<28)+(1<<35),
            (1<<30)+(1<<24)+(1<<31),
            (1<<31)+(1<<25)+(1<<30),
            (1<<32)+(1<<26)+(1<<31)+(1<<33),
            (1<<33)+(1<<27)+(1<<32)+(1<<34),
            (1<<34)+(1<<28)+(1<<33)+(1<<35),
            (1<<35)+(1<<29)+(1<<34),
            
        },
    };
    
    i no longer need an array, i made a new function to tell which lights to turn on.
    Code:
    for (int i=4; i<9; i++)
        {
        
        int iHeight = i;
        int iWidth = i;
        
        // don't do anything if it won't fit in 64 bits
        if (iHeight * iWidth > 64) return;
        
        for (int iCurButton = 0; iCurButton < iWidth * iHeight; iCurButton++)
        {
            int iSumLow32 = 0;
            int iSumHigh32 = 0;
            
            if (iCurButton < 32) {
                iSumLow32=1<<iCurButton;  
            }
            else {
                iSumHigh32=1<<(iCurButton - 32);
            }
            
            if (iCurButton % iWidth > 0){ //not left side
                if (iCurButton - 1 < 32){
                    iSumLow32 += 1 << (iCurButton - 1);
                }
                else
                {
                    iSumHigh32 += 1 << ((iCurButton - 1) - 32);
                }
            }
            if ((iCurButton + 1) % iWidth > 0){ //not right side
                if (iCurButton + 1 < 32){
                    iSumLow32 += 1 << (iCurButton + 1);
                }
                else
                {
                    iSumHigh32 += 1 << ((iCurButton + 1) -32);
                }
            }
            if (iCurButton >= iWidth){ //not top row
                if (iCurButton - iWidth < 32){
                    iSumLow32 += 1 << (iCurButton - iWidth);
                }
                else
                {
                    iSumHigh32 += 1 << ((iCurButton - iWidth) - 32);
                }
            }
            if (iCurButton < iWidth * (iHeight -1)){ //not bottom row
                if (iCurButton + iWidth < 32){
                    iSumLow32 += 1 << (iCurButton + iWidth);
                }
                else
                {
                    iSumHigh32 += 1 << ((iCurButton + iWidth) - 32);
                }
            }
            myButtonFunctionsFirst32 [i] [iCurButton]=iSumLow32;
            myButtonFunctionsLast32 [i]  [iCurButton]=iSumHigh32;
        }
        }
    
    i was planning on making different size grids, 4x4 through 8x8

    I am currently not having any problems, but it would still be nice to have 1 set of bits instead of 2

    Please Register or Log in to view images

Share This Page