[freenet-devl] Re: Yet another GCJ update. (a/k/a PR 1615followup)

Mark J. Roberts mjr@statesmean.com
Tue Feb 20 16:51:00 GMT 2001


On 20 Feb 2001, Per Bothner wrote:

> Since the divide code in BigInteger is essentially the same as that
> of gnu.math.IntNum, it should be possible to just trace the methods
> in parallel.  For example, you could put print statements at

It turns out that I stupidly broke MPN.lshift in my local tree. After
checking out and rebuilding the problem went away.

However, I've observed the problem Warren was talking about, where mod
will sometimes return negative values, in modPow. This is almost certainly
the sole cause of the bogus results. Here's one example (run with a fresh
checkout from two weeks ago, because the current tree won't build):

import java.math.BigInteger;

public class Test {
    public static void main(String[] args) {
        BigInteger T = new BigInteger("5363477215576024080352146054728591738975281035361379918407897276030282252479044783172001966482124029245302093014626956280098651201847836216374332950814156027796031970089530772567198844540478606663360863662982144100698818201936974835332520383090511574799397295905577792338599750686001448568828905655763917313563120386381736094675297207329643252030689325796326393513686312486148032833036096820605171025669273725454314972290063049224854036602538113932389162867536712558822172300766315970163135148437799010614366362123974533532312110376260378827191951510492718117946527530776244985915470382938249329088732460055997031872446501747175237824859137346490214391270674064953933158320812599701614974281913326681871516572015772353043141917759412318519441534799423877409909559315542461484396915489248651712166091921308821586330549519818476196339327520964184414122294009132924500801546671051632080152337153933150331961");
        BigInteger M = new BigInteger("506508470987540265583429893672764919338584695781284128237891625244595347040426767932405572139896391577884162883434949952948462196304077471174719892005834947687880564311402595131167639980270063376187010458213126477615564918614795640032613646421706171188320701390641189056294472557282632830853673226973603727879535583554406954359168504378750389422314954246063489458978896295369827275737598768721807358516399796941727769804763095763576037635067035670376540");
        System.out.println(T.mod(M));
    }
}


mjr::mjr$ gcj --main=Test -o test BigInteger.java Test.java ; ./test
-193777487871550603802886620051223065684360061219665906255308989122864946160997365672261816618860360252622577515551548542184701363470270624007177647259538860643091504310327081344962114919427392852996299736514123723159307151561050854215732124890528507748420958460751229013619680798445437564005061662750554072049469772786792714325591967543809251820954350423827422639100041962237582007598963943407454570694092539420011326781748166365585036273383824881872855
mjr::mjr$ javac Test.java ; java -cp . Test
367417105895394016159154787313270662212024192865627354929903779273790475448015789586251477566499147933827828993175451736204011419593248732059558975428536352923147799454938474886826728465908014291590615212928094348062380180678090626190405785338510862566219882367271848354528305975332648128732693695418736716973797590695732844596436204184266800584120723714967834374864490790434309625243649395288704661308708314268453615305198754248602412105555586454917161
mjr::mjr$


-- 
Mark Roberts
mjr@statesmean.com




More information about the Java mailing list