This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ocean-city
Recipients higstar, ned.deily, ocean-city, r.david.murray, stutzbach, theller
Date 2010-10-03.18:02:58
SpamBayes Score 0.00035448855
Marked as misclassified No
Message-id <1286128980.78.0.636402909366.issue6493@psf.upfronthosting.co.za>
In-reply-to
Content
Sorry,my patch didn't work again... Because of this
compiler behavior. Is this ANSI standard?

#include <stdio.h>

typedef unsigned __int32 uint32;

static void
print_bits(uint32 n)
{
    int i;

    for (i = 31; i >= 0; --i)
    {
        printf("%c", (n & (1 << i)) ? '1' : '0');
    }
    printf(" : %X\n", n);
}

int main()
{
    uint32 n;

    n = 1;
    print_bits(n << 30);
    print_bits(n << 31);
    print_bits(n << 32);
    print_bits((n << 31) << 1);
}

R:\test\bitshift>a
01000000000000000000000000000000 : 40000000
10000000000000000000000000000000 : 80000000
00000000000000000000000000000001 : 1
00000000000000000000000000000000 : 0

I thought n << 32 should be 0. I hope new patch
is somehow better.
History
Date User Action Args
2010-10-03 18:03:00ocean-citysetrecipients: + ocean-city, theller, ned.deily, stutzbach, r.david.murray, higstar
2010-10-03 18:03:00ocean-citysetmessageid: <1286128980.78.0.636402909366.issue6493@psf.upfronthosting.co.za>
2010-10-03 18:02:59ocean-citylinkissue6493 messages
2010-10-03 18:02:58ocean-citycreate