Opened 3 years ago

Last modified 9 days ago

#28704 new defect

Inconsistent cmp for p-adics

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

GitHub link to the corresponding issue

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 (10)

comment:1 Changed 3 years ago by embray

Milestone: sage-9.0sage-9.1

Ticket retargeted after milestone closed

comment:2 Changed 3 years ago by mkoeppe

Milestone: sage-9.1sage-9.2

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

comment:3 Changed 2 years ago by mkoeppe

Milestone: sage-9.2sage-9.3

comment:4 Changed 21 months ago by mkoeppe

Milestone: sage-9.3sage-9.4

Moving to 9.4, as 9.3 has been released.

comment:5 Changed 18 months ago by mkoeppe

Milestone: sage-9.4sage-9.5

comment:6 Changed 14 months ago by mkoeppe

Milestone: sage-9.5sage-9.6

comment:7 Changed 9 months ago by mkoeppe

Milestone: sage-9.6sage-9.7

comment:8 Changed 5 months ago by mkoeppe

Milestone: sage-9.7sage-9.8

comment:9 Changed 4 weeks ago by chapoton

Cc: caruso added; xcaruso removed

comment:10 Changed 9 days ago by mkoeppe

Milestone: sage-9.8
Note: See TracTickets for help on using tickets.