On 10 January 2012 17:22, Jim Jewett <[email protected]> wrote: > On Mon, Jan 9, 2012 at 12:59 PM, [email protected] > <[email protected]> wrote: > > Or maybe it's considered not pythonic to use > > > int(1.3) > > > instead of > > > from math import floor > > floor(1.3) > > > But I doubt that... > > Your hint is too subtle -- having int truncate non-integers was a > regret that caused the introduction of __index__ (for "as an integer") > on things that really are integers. > > So now there really are several numeric types that won't (or at least > won't always) respond to int, precisely because you should specify > what sort of rounding you want. Sympy probably should follow that > policy, and is therefore doing the right thing. (That said, I won't > get involved if you want some sort of context with default decisions. > The Decimal module may provide useful guidance.) > The stuff about __index__ is completely new for me and it seems quite interesting. Could you explain a bit more why it is a problem when int truncates floats or point me to some resource on the question?
> > -jJ > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
