⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signedmutablebiginteger.java

📁 java源代码 请看看啊 提点宝贵的意见
💻 JAVA
字号:
/* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *//* * @(#)SignedMutableBigInteger.java	1.8 03/01/23 */package java.math;/** * A class used to represent multiprecision integers that makes efficient * use of allocated space by allowing a number to occupy only part of * an array so that the arrays do not have to be reallocated as often. * When performing an operation with many iterations the array used to * hold a number is only increased when necessary and does not have to * be the same size as the number it represents. A mutable number allows * calculations to occur on the same number without having to create * a new number for every step of the calculation as occurs with * BigIntegers. * * Note that SignedMutableBigIntegers only support signed addition and * subtraction. All other operations occur as with MutableBigIntegers. *  * @see     BigInteger * @version 1.8, 01/23/03 * @author  Michael McCloskey * @since   1.3 */class SignedMutableBigInteger extends MutableBigInteger {   /**     * The sign of this MutableBigInteger.     */    int sign = 1;    // Constructors    /**     * The default constructor. An empty MutableBigInteger is created with     * a one word capacity.     */    SignedMutableBigInteger() {        super();    }    /**     * Construct a new MutableBigInteger with a magnitude specified by     * the int val.     */    SignedMutableBigInteger(int val) {        super(val);    }    /**     * Construct a new MutableBigInteger with a magnitude equal to the     * specified MutableBigInteger.     */    SignedMutableBigInteger(MutableBigInteger val) {        super(val);    }   // Arithmetic Operations   /**     * Signed addition built upon unsigned add and subtract.     */    void signedAdd(SignedMutableBigInteger addend) {        if (sign == addend.sign)            add(addend);        else            sign = sign * subtract(addend);    }   /**     * Signed addition built upon unsigned add and subtract.     */    void signedAdd(MutableBigInteger addend) {        if (sign == 1)            add(addend);        else            sign = sign * subtract(addend);            }   /**     * Signed subtraction built upon unsigned add and subtract.     */    void signedSubtract(SignedMutableBigInteger addend) {        if (sign == addend.sign)            sign = sign * subtract(addend);        else            add(addend);            }   /**     * Signed subtraction built upon unsigned add and subtract.     */    void signedSubtract(MutableBigInteger addend) {        if (sign == 1)            sign = sign * subtract(addend);        else            add(addend);        if (intLen == 0)             sign = 1;    }    /**     * Print out the first intLen ints of this MutableBigInteger's value     * array starting at offset.     */    public String toString() {        BigInteger b = new BigInteger(this, sign);        return            b.toString();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -