Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Difference between RealNumber and RealLiteral

I discovered this tonight.

sage: L = srange(-1,1,.01)
sage: type(L[50])
<type 'sage.rings.real_mpfr.RealNumber'>
sage: type(-.5)
<type 'sage.rings.real_mpfr.RealLiteral'>

and hence

sage: -.5 in L
False

In some sense I'm cool with that, but in another sense I'm very annoyed. (Especially since I probably should have known about it but missed this.) So ... what exactly is the difference between these types, and when should they each be used? You might see my confusion given this result:

sage: L[50] in RR
True
sage: -.5 in RR
True

Also, perhaps if anyone ever makes the full list of real numbers types as in Question 9950, one could add these.

Difference between RealNumber and RealLiteral

I discovered this tonight.

sage: L = srange(-1,1,.01)
sage: type(L[50])
<type 'sage.rings.real_mpfr.RealNumber'>
sage: type(-.5)
<type 'sage.rings.real_mpfr.RealLiteral'>

and hence

sage: -.5 in L
False

In some sense I'm cool with that, but in another sense I'm very annoyed. (Especially since I probably should have known about it but missed this.) So ... what exactly is the difference between these types, and when should they each be used? You might see my confusion given this result:

sage: L[50] in RR
True
sage: -.5 in RR
True

Oh, and this is really awesome:

sage: type(RealNumber(-.5))
<type 'sage.rings.real_mpfr.RealLiteral'>

Also, perhaps if anyone ever makes the full list of real numbers types as in Question 9950, one could add these.