[sage-support] Re: Comparison of approximate real numbers

2012-06-12 Thread Volker Braun
On Tuesday, June 12, 2012 3:16:15 AM UTC+1, Jason Grout wrote: You never compare decimal numbers exactly on a computer. Because of finite precision, there almost always will be corner cases that will catch you. Instead, do something like: sage: 10.44-10.30 0.139 Don't

[sage-support] Re: Comparison of approximate real numbers

2012-06-12 Thread rych
Interval arithmetics also gives False, sage: from mpmath import iv sage: # iv.prec = 24 sage: # iv.prec = 53 # for double precision sage: x = 0.1 sage: iv.prec = x.prec() # precision of Sage Real numbers, 53 sage: iv.pretty = True sage: iv.mpf('10.44') [10.439503,

Re: [sage-support] Re: Comparison of approximate real numbers

2012-06-12 Thread William Stein
On Tue, Jun 12, 2012 at 3:54 PM, rych rych...@gmail.com wrote: Interval arithmetics also gives False, sage: from mpmath import iv sage: # iv.prec = 24 sage: # iv.prec = 53 # for double precision sage: x = 0.1 sage: iv.prec = x.prec() # precision of Sage Real numbers, 53 sage: iv.pretty =

Re: [sage-support] Re: Comparison of approximate real numbers

2012-06-12 Thread Robert Bradshaw
On Tue, Jun 12, 2012 at 4:11 PM, William Stein wst...@gmail.com wrote: On Tue, Jun 12, 2012 at 3:54 PM, rych rych...@gmail.com wrote: Interval arithmetics also gives False, sage: from mpmath import iv sage: # iv.prec = 24 sage: # iv.prec = 53 # for double precision sage: x = 0.1 sage:

[sage-support] Re: Comparison of approximate real numbers

2012-06-11 Thread Jason Grout
On 6/11/12 6:45 PM, Kwankyu wrote: Hi all, I am puzzled. sage: 10.44-10.30==0.14 False How should I compare them to get True? Suddenly Sage feels very alien to me. :-) You never compare decimal numbers exactly on a computer. Because of finite precision, there almost always will be corner