On Fri, Oct 8, 2010 at 1:27 PM, Tom Limoncelli <t...@whatexit.org> wrote:
> I see this in code now and then:
>
>                1<<16-1
>
> Python and C interpret that as "1 << (16 - 1)", which is 32768.
>
> The programmer usually means "(1 << 16) - 1", which is 65535.
>
> There's a big difference, especially if you are using these for bit masks:
>
> 32768 = 1000000000000000
> 65535 = 1111111111111111
>
> Tom

P.S.  You can use Google Code Search to find other people that make
this mistake:

http://www.google.com/codesearch?hl=en&lr=&q=1%3C%3C16-1&btnG=Search



-- 
http://EverythingSysadmin.com  -- my blog (new posts Mon and Wed)
http://www.TomOnTime.com -- my advice (more videos coming soon)

_______________________________________________
Tech mailing list
Tech@lopsa.org
http://lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to