src/java.base/share/classes/java/math/BigInteger.java

Print this page
8152237 Support BigInteger.TWO
   1 /*
   2  * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1249             powerCache[i] = new BigInteger[] { BigInteger.valueOf(i) };
1250             logCache[i] = Math.log(i);
1251         }
1252     }
1253 
1254     /**
1255      * The BigInteger constant zero.
1256      *
1257      * @since   1.2
1258      */
1259     public static final BigInteger ZERO = new BigInteger(new int[0], 0);
1260 
1261     /**
1262      * The BigInteger constant one.
1263      *
1264      * @since   1.2
1265      */
1266     public static final BigInteger ONE = valueOf(1);
1267 
1268     /**
1269      * The BigInteger constant two.  (Not exported.)


1270      */
1271     private static final BigInteger TWO = valueOf(2);
1272 
1273     /**
1274      * The BigInteger constant -1.  (Not exported.)
1275      */
1276     private static final BigInteger NEGATIVE_ONE = valueOf(-1);
1277 
1278     /**
1279      * The BigInteger constant ten.
1280      *
1281      * @since   1.5
1282      */
1283     public static final BigInteger TEN = valueOf(10);
1284 
1285     // Arithmetic Operations
1286 
1287     /**
1288      * Returns a BigInteger whose value is {@code (this + val)}.
1289      *
1290      * @param  val value to be added to this BigInteger.
1291      * @return {@code this + val}


   1 /*
   2  * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1249             powerCache[i] = new BigInteger[] { BigInteger.valueOf(i) };
1250             logCache[i] = Math.log(i);
1251         }
1252     }
1253 
1254     /**
1255      * The BigInteger constant zero.
1256      *
1257      * @since   1.2
1258      */
1259     public static final BigInteger ZERO = new BigInteger(new int[0], 0);
1260 
1261     /**
1262      * The BigInteger constant one.
1263      *
1264      * @since   1.2
1265      */
1266     public static final BigInteger ONE = valueOf(1);
1267 
1268     /**
1269      * The BigInteger constant two.
1270      *
1271      * @since   9
1272      */
1273     public static final BigInteger TWO = valueOf(2);
1274 
1275     /**
1276      * The BigInteger constant -1.  (Not exported.)
1277      */
1278     private static final BigInteger NEGATIVE_ONE = valueOf(-1);
1279 
1280     /**
1281      * The BigInteger constant ten.
1282      *
1283      * @since   1.5
1284      */
1285     public static final BigInteger TEN = valueOf(10);
1286 
1287     // Arithmetic Operations
1288 
1289     /**
1290      * Returns a BigInteger whose value is {@code (this + val)}.
1291      *
1292      * @param  val value to be added to this BigInteger.
1293      * @return {@code this + val}