I really hope there is some clearer documentation than those code comments, since I am even more confused after reading that than after seeing the original post.
sage: a = RIF(1.332,1.334) sage: a.center() 1.33300000000000 sage: a 1.34? The center is 1.33 and we know that the value is "really" between 1.332 and 1.334 so the first two decimal places after the point are certainly 33. How on earth is 1.34? supposed to convey that? On Sage 5.11.beta3 I get sage: a = RIF(0,123) sage: a 1.?e2 and not '62.?62' which I suppose is intended to convey "61.5 plus-or-minus 61.5'. So is that comment in the code out of date? I think the interval arithmetic is great, and very useful, but the output format is so bizarre I wonder whether if it is putting users off using it. John On 6 August 2013 13:30, Jason Grout <jason-s...@creativetrax.com> wrote: > On 8/6/13 7:07 AM, Daniel Krenn wrote: >> >> Hi, >> >> I have the following: >> >> sage: RIF(1.332,1.334), RIF(1.332,1.334).str(style='brackets') >> (1.34?, '[1.3320000000000000 .. 1.3340000000000001]') >> >> This is not wrong, since the questionmark means +/-1 on the previous >> digit. But why is the resulting string not 1.33?, which would be more >> "natural" to me? Is there a reason for doing so? > > > I think the default is to pick a 'center' point that is furthest from zero, > all else being equal. This makes it clearer when an interval is all one > sign. See the documentation here: > > https://github.com/sagemath/sage/blob/master/src/sage/rings/real_mpfi.pyx#L1569 > > "When there are two > possible results of equal precision and with the same error width, > then we pick the one which is farther from zero. (For instance, > ``RIF(0, 123)`` with two error digits could print as ``61.?62`` or > ``62.?62``. We prefer the latter because it makes it clear that the > interval is known not to be negative.)" > > > Thanks, > > 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. > 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. For more options, visit https://groups.google.com/groups/opt_out.