unsigned integer?

Dan Bishop danb_83 at yahoo.com
Sat Mar 10 13:21:24 EST 2007


On Mar 10, 11:50 am, Duncan Booth <duncan.bo... at invalid.invalid>
wrote:
> "Jack" <nos... at invalid.com> wrote:
> > This is a naive question:
>
> > "%u" % -3
>
> > I expect it to print 3. But it still print -3.
>
> Internally it uses the C runtime to format the number, but if the number
> you ask it to print unsigned is negative it uses %d instead of %u. I have
> no idea if it is actually possibly to get a different output for %d versus
> %u.

%u used to be different from %d, but it changed because of the int/
long unification in Python 2.4.




More information about the Python-list mailing list