On Tue, Sep 6, 2011 at 10:15 PM, Chris Seberino <[email protected]> wrote: > This slider will display the corresponding numbers as the slider is > moved.... > > @interact > def _(a=slider(1, 2, 0.2)): > print "test" > > The problem is the numbers have too many digits for my taste... > > e.g. 1.00000000000000, 1.20000000000000, 1.40000000000000, etc. > > How truncate or round or format?
Here is one way: @interact def _(a=slider(1, 2, RealField(5)(.2))): print "test", a, RR(a), RR(str(a)) Note -- here a will be a 5-bit real number, so you may want to convert it to a full 53-bit number before using it. One way to do that which will preserve the *print output* is RR(str(a)). That will probably be less confusing to users than RR(a). William > > Thanks! > > Chris > > -- > 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/sage-support > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- 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/sage-support URL: http://www.sagemath.org
