9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Julius Schmidt <aiju@phicode.de>
To: 9front@9front.org
Subject: mpmod aliasing
Date: Sun, 5 Feb 2017 01:09:11 +0100 (CET)	[thread overview]
Message-ID: <alpine.LNX.2.00.1702050108240.4258@phi> (raw)

mpmod has a bug when n==r and x is negative.
my best attempt at a fix:

void
mpmod(mpint *x, mpint *n, mpint *r)
{
 	int sign;
 	mpint *ns;

 	sign = x->sign;
 	ns = sign < 0 && n == r ? mpcopy(n) : n;
 	if((n->flags & MPfield) == 0
 	|| ((Mfield*)n)->reduce((Mfield*)n, x, r) != 0)
 		mpdiv(x, n, nil, r);
 	if(sign < 0)
 		mpmagsub(ns, r, r);
 	if(ns != n) mpfree(ns);
}



             reply	other threads:[~2017-02-05  0:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-05  0:09 Julius Schmidt [this message]
2017-02-05  0:26 ` [9front] " Nick Owens
2017-02-05  1:40 ` cinap_lenrek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1702050108240.4258@phi \
    --to=aiju@phicode.de \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).