On Fri, Apr 3, 2009 at 5:52 AM, Marco Streng <marco.str...@gmail.com> wrote: > > I found that in Sage 3.4, > True * Integer(2) returns int(1) > > I think it would be better if the output were either 2 or a type > error. This seems to be a problem with Sage integers, python integers > work just fine.
More generally, it would seem that bool * (any Sage element) returns int(1) if the Sage element is nonzero and the bool is True, and otherwise returns int(0): sage: True*(2/3) 1 sage: True*x 1 sage: type(True*x) <type 'int'> sage: False*(2/3) 0 sage: True*0 0 Since this is inconsistent with Python's conventions, I think it should be changed. The most natural change would be to canonically coerce bool to the Python ints 0 and 1, then do the multiply, since then everything works as it should. This will require some change to coerce.pyx, which would be easiest for Robert Bradshaw to make... William > > Some more details: > ---------------------------------------------------------------------- > | Sage Version 3.4, Release Date: 2009-03-11 | > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > sage: True*1341234874 > 1 > sage: True*int(1341234874) > 1341234874 > sage: type(True*1341234874) > <type 'int'> > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---