Ask Your Question

Revision history [back]

Comparison in number fields is not satisfactory in Sage.

The current implementation (except in some special cases) seems to be that

  • > always returns True,
  • < always returns False.

That is the case with b defined as in your example:

sage: b > 0
True
sage: 0 > b
True
sage: b < 0
False
sage: 0 < b
False

Comparison works well in quadratic number fields since ticket #13213.

The method is_real_positive() from ticket #8347 works in some number fields (but unfortunately not in the field Qb in your question).