sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.31k stars 450 forks source link

Inconsistent cmp for p-adics #28704

Open saraedum opened 4 years ago

saraedum commented 4 years ago

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.

CC: @roed314 @slel @xcaruso

Component: padics

Keywords: cmp

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

embray commented 4 years ago
comment:1

Ticket retargeted after milestone closed

mkoeppe commented 4 years ago
comment:2

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

mkoeppe commented 3 years ago
comment:4

Moving to 9.4, as 9.3 has been released.