Skip to content

conversion of string to complex number with sage_eval should be avoided #30977

@edgarcosta

Description

@edgarcosta

At the moment, a string is converted complex number with the aid of sage_eval, however, if the precision of the field is larger than the precision of the RealLiteral this leads to inconsistent results:

sage: R = ComplexField(57)
....: S = R._real_field()
....: S("-13.59658451496887") == R("-13.59658451496887").real()
True
sage: R("-13.59658451496887*I") ==  R("-13.59658451496887")*I
False
sage: R("-13.59658451496887*I") ==  R("0", "-13.59658451496887")
False
sage: R("0", "-13.59658451496887") == R("-13.59658451496887")*I
True
sage: R(-13.59658451496887*I) == R("-13.59658451496887*I")
True
sage: (-13.59658451496887*I).parent()
Complex Field with 54 bits of precision

In #29979, a doctest was marked not tested because of this, which should be reverted once the problem is solved.

Component: coercion

Issue created by migration from https://trac.sagemath.org/ticket/30977

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions