unicode mystery

B

Bengt Richter

Why not just -2x11? IMHO, Py2.4 does not produce negative values out of
hex or oct literals any longer, so your proposal would be inconsistent.
Inconsistent with what? This is a new based-literal representation, not
the old hex or octal representation. It is separate and self-consistent,
and can live along side the old.

The fact that there is no longer a way to represent negative numbers
with traditional octal or hex is due to getting away from the
platform-dependent assumptions that bit 31 was a sign bit of a 32-bit
two-s complement machine represenentation. That was a good thing to get
away from.

But it means you now have to write a unary minus expression for negative numbers,
not a self-contained literal.

Re your question, -2x11 is the same as -(2x11) so you have to decide what
you want 2x11 to mean. If it means +3, we are back to the original problem
of having no way to see any of the 111111111111....101 or ffff....fd of a -3 ;-)
(Except of course by '%02x'%(-0x3&0xff) -- ick)

I am not proposing a change to the new Py2.4 positive-only hex and octal literals.
I just want to be able to write literals for both positive and negative numbers
as self-contained literals (not expressions) without a '-' sign, and have the
representation be a readable representation of typical twos-complement representation.
You can't do that with -0x3, because (though the expression equals -3) it doesn't show
the information about the bits that you get with 16xfd or 2x101. Note that -16xfd == 16x03
and -2x101 == 2x011 and -16x03 == 16xfd and -2x011 == 2x101.

The '-' sign is not part of the literal.

Regards,
Bengt Richter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top