srange gives a list of Sage integers and follows the syntax of range. On Fri, Sep 5, 2008 at 5:41 PM, Harald Schilly <[EMAIL PROTECTED]> wrote: > > hello roland > > I cross posted this on the sage-support mailing list > http://groups.google.com/group/sage-support > > regarding your bugreport: > http://spreadsheets.google.com/pub?key=pCwvGVwSMxTzT6E2xNdo5fA > >> In loop "/' operand incorrect >> Hi. Please view worksheet which is publicly viewable at >> http://75.75.6.176:80/home/pub/0 >> In a loop, and only then, suddenly 583/2 becomes 291 ...? >> Roland, sage 3.1.1 on Windows/VMWare > > the "problem" is, that range is a native python command and all this > happens because it is python "only". > if you just enter numbers, sage preparses them as "Integer(n)" .. then > they are more complex objects. > > there is not much to do about this, either convert to sage integers or > well, someone has to break python - but that's extremely dangerous. > > so, as long as i understood your lengthy example correct, here are two > commands, run in "pure" python to clarify: > >>>> for i in range(1,6): print i/2 > ... > 0 > 1 > 1 > 2 > 2 > >>>> for i in range(1,6): print float(i)/2 > ... > 0.5 > 1.0 > 1.5 > 2.0 > 2.5 > > ----- > in sage > > sage: preparse("for i in range(1,6): print i/2") > 'for i in range(Integer(1),Integer(6)): print i/Integer(2)' > > above, division by an integer! > > sage: for i in range(1,6): print i/2 > ....: > 1/2 > 1 > 3/2 > 2 > 5/2 > > > also, you can use the "type" command to get the objects type. native > integers are "int" and sage's "Integer" > > h > > > >
--~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---