This seems weird to me:

sage: (-10).bits()
[0, -1, 0, -1]

It makes it look like binary now includes -1 along with 0 and 1, making
it..ternary?

I guess that the bits() function is supposed to satisfy 

  x == sum(b*2^e for e, b in enumerate(x.bits()))

...but you have to interpret b as a regular integer -- and not a bit --
for that to be true, since -1 equals 1 in the integers mod 2. And
indeed, the parent of all the "bits" is the Integer Ring and not GF(2)
or Integers(2).

At the very least, I think this deserves a note in the bits()
documentation. Or, what might be less popular, a change to bits() to
somehow return a sign -- maybe a tuple (sign, [list of bits])?

Thoughts?

Dan

--
---  Dan Drake
-----  http://math.pugetsound.edu/~ddrake
-------

Attachment: signature.asc
Description: Digital signature

Reply via email to