[C++-sig] problem about conertting c++ method to python

David Abrahams dave at boost-consulting.com
Tue Jul 18 16:46:52 CEST 2006


sam wang <samwzm at yahoo.com> writes:

> hi, there,
>
> I want to convert a little c++ method to python. it just retrieves the length of some unsigned
> values from a vector according to some rules.
>
> one of them seems work while another one didn't work, could you please let me know what's wrong
> and how I should correct it?
>
> any hint will great appreciate!
> Sammy

You seem to have an expectation that a Python int will exhibit modular
arithmetic like a C++ unsigned int will (if unsigned int is 32 bits).
Try

     python -c "print 1 << 157"

and see what you get. :)

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list