That doesn't play well with indexing:
sage: bin(-10)[3] '1' sage: bin(-10)[2] 'b' On Fri, Feb 15, 2013 at 8:49 PM, Jason Grout <jason-s...@creativetrax.com> wrote: > On 2/15/13 1:29 PM, Dan Drake wrote: >> >> 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? > > > FYI, here's what python does: > >>>> bin(-10) > '-0b1010' > > Jason > > > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-devel?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.