tests/libjava-mauve/src/gnu/testlet/java/math/BigInteger/shift.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Test of shiftRight and shiftLeft methods of BigInteger.
       
     2 
       
     3 /*************************************************************************
       
     4 /* This program is free software; you can redistribute it and/or modify
       
     5 /* it under the terms of the GNU General Public License as published 
       
     6 /* by the Free Software Foundation, either version 2 of the License, or
       
     7 /* (at your option) any later version.
       
     8 /*
       
     9 /* This program is distributed in the hope that it will be useful, but
       
    10 /* WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 /* GNU General Public License for more details.
       
    13 /*
       
    14 /* You should have received a copy of the GNU General Public License
       
    15 /* along with this program; if not, write to the Free Software Foundation
       
    16 /* Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
       
    17 /*************************************************************************/
       
    18 
       
    19 // Tags: JDK1.1
       
    20 
       
    21 package gnu.testlet.java.math.BigInteger;
       
    22 
       
    23 import java.math.BigInteger;
       
    24 import gnu.testlet.Testlet;
       
    25 import gnu.testlet.TestHarness;
       
    26 
       
    27 public class shift implements Testlet
       
    28 {
       
    29   public void test (TestHarness harness)
       
    30   {
       
    31     harness.checkPoint ("shift");
       
    32     BigInteger x =
       
    33       new BigInteger ("-50123044517898350982301255831878893568", 10);
       
    34     harness.check (x.shiftRight(64).toString(), "-2717175687894652269");
       
    35     harness.check (x.shiftLeft(-64).toString(), "-2717175687894652269");
       
    36     harness.check (x.shiftRight(1).toString(),
       
    37       "-25061522258949175491150627915939446784");
       
    38     harness.check (x.shiftLeft(1).toString(), 
       
    39       "-100246089035796701964602511663757787136");
       
    40 
       
    41     harness.check (x.shiftRight(0).toString(), x.toString());
       
    42     harness.check (x.shiftLeft(0).toString(), x.toString());
       
    43 
       
    44     x = new BigInteger ("50123044517898350982301255831878893568", 10);
       
    45     harness.check (x.shiftRight(64).toString(), "2717175687894652268");
       
    46     harness.check (x.shiftLeft(-64).toString(), "2717175687894652268");
       
    47     harness.check (x.shiftRight(1).toString(),
       
    48       "25061522258949175491150627915939446784");
       
    49     harness.check (x.shiftLeft(1).toString(), 
       
    50       "100246089035796701964602511663757787136");
       
    51   }
       
    52 }