[C++-sig] Re: Re: long long unsigned issue...
dave at boost-consulting.com
Sun May 4 03:44:00 CEST 2003
"Milind Patil" <milind_patil at hotmail.com> writes:
>> > This is best converted to Y(int) constructor.
> Because if I have constructor Y(long unsigned unsigned int) precede
> Y(int) (and you rightly said it masks the int), then I get
> OverflowError: bad numeric cast: loss of range in numeric_cast
> for the python statement z = hello.Y(-1). There is no way to convert a
> python -1L to a c++ long long unsigned int.
OK, I understand.
>> > I read up a bit on python long and learned that it is not like the
>> > c++ long. It seems the python long is a structure and is not width
>> > bound. How does boost handle python boost to long conversion?
>> What is "python boost to long conversion"? Please be specific.
> I meant python long to c++ long conversion by boost. For example,
> what happens if the python long is more than 64 bits wide?
If it doesn't fit in a C++ long (not neccessarily 64 bits), you'll
get an overflow error.
BTW, a Python int is precisely the same number of bits as a C++ long.
I don't know if that helps you at all.
BTW2, Boost.Python has a "long_" type which corresponds precisely to
a Python long. You can use that in your constructor.
> How do I handle this in c++?
I guess it depends on the behavior you're trying to achieve. Can you
explain precisely what you're after?
More information about the Cplusplus-sig