Opened 2 years ago

Last modified 3 months ago

#28704 new defect

Inconsistent cmp for p-adics

Reported by: saraedum Owned by:
Priority: minor Milestone: sage-9.5
Component: padics Keywords: cmp
Cc: roed, slelievre, xcaruso Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

As reported in https://ask.sagemath.org/question/48658/possible-bug-in-_cmp_-function/ cmp is inconsistent for p-adics, i.e., a<b does not imply b>a. While ordering p-adics has no deep meaning, it should at least be consistent.

The problem seems to be in ccmp doing the following

    mpz_sub(holder.value, a, b)
    mpz_mod(holder.value, holder.value, prime_pow.pow_mpz_t_tmp(prec))
    return mpz_sgn(holder.value)

But mpz_mod is always non-negative.

Change History (5)

comment:1 Changed 2 years ago by embray

  • Milestone changed from sage-9.0 to sage-9.1

Ticket retargeted after milestone closed

comment:2 Changed 19 months ago by mkoeppe

  • Milestone changed from sage-9.1 to sage-9.2

Moving tickets to milestone sage-9.2 based on a review of last modification date, branch status, and severity.

comment:3 Changed 14 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3

comment:4 Changed 7 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Moving to 9.4, as 9.3 has been released.

comment:5 Changed 3 months ago by mkoeppe

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