[issue30571] Add integer formatting code for fixed-width signed arithmetic (2's complement)

Raymond Hettinger report at bugs.python.org
Mon Jun 12 04:00:04 EDT 2017


Raymond Hettinger added the comment:

This is a recurring need in my teaching of Python to hardware engineers.   The whole point of having a binary format code is to show which bits are set.  For negative values, that need is not being served by the current option.  And it makes it awkward when modeling the effects of bitwise operations on signed numbers.

I can understand a -1 if you think this is fundamentally broken, but if you're just saying that you've never personally needed this or casually dismissing the awkwardness of the usual workarounds, then it seems like a meaningless vote that blows-off my proposal which is based on real-world classroom experiences.

The idea is that modifier (such as "!" would require a width argument (the signed representation only make sense in fixed width concepts as every assembly language programmer knows).  Its presence would also imply the "0".

Serhiy, I believe you've either read different maillist posts than I have or that you're misinterpreting this as a proposal for a fixed width integer type with automatic wrap-around and truncation (full emulation of a register).  This proposal is for display formatting only.  IMO, it remedies a deficiency where the current option is more for our convenience (not wanting to deal with the width) rather than for the user's convenience where the user wants to see which bits are set rather than seeing a minus sign (which is both obvious and useless).

Also, when a senior coredev presents a proposal, I expect that it will be greeted with a little more open mindedness and not instantly shot down as if I have no idea what I'm talking about.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30571>
_______________________________________


More information about the Python-bugs-list mailing list