Opened 9 years ago

# Comparison of python and sage complex numbers

Reported by: Owned by: tscrim tscrim major sage-6.4 basic arithmetic N/A

### Description

We have the following behavior:

```sage: complex('inf')
(inf+0j)
sage: CC(oo)
+infinity

sage: complex('inf') < complex(0) # This is good
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-84-743f29f99a3c> in <module>()
----> 1 complex('inf') < complex(Integer(0))

TypeError: no ordering relation is defined for complex numbers

sage: complex('inf') < float(0) # Still good
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-85-ec0c40060e5d> in <module>()
----> 1 complex('inf') < float(Integer(0))

TypeError: no ordering relation is defined for complex numbers

# These are all not good
sage: complex('inf') < 0
True
sage: complex(oo) < RR(0)
True
sage: complex(oo) < RR(oo)
False
sage: complex(oo) < RR(-oo)
True
```

We also have the comparison failures with sage's complex infinity:

```sage: CC(oo) < 0 # This is okay
False
sage: CC(oo) > 0
True
sage: CC(oo) > CC(2+5*i)
True
sage: CC(2+4*i) < CC(2+5*i)
True
sage: CC(2+6*i) < CC(2+5*i)
False
```

I believe all comparisons in the complex number should raise a `TypeError` to be consistent with python. The other alternative should be they always return `False`.

There is also the related #11506.

### comment:1 Changed 9 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

### comment:2 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

### comment:3 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

### comment:4 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.