jdk源码学习java.math包

阅读JDK源代码java.math中的

java.math.BigDecimal
java.math.BigInteger
java.math.BitSieve
java.math.MathContext
java.math.MutableBigInteger
java.math.RoundingMode
java.math.SignedMutableBigInteger

1、java.math.BigDecimal
不可变的、任意精度的有符号十进制数。BigDecimal 由任意精度的整数非标度值 和 32 位的整数标度 (scale) 组成。
如果为零或正数,则标度是小数点后的位数。如果为负数,则将该数的非标度值乘以 10 的负 scale 次幂。因此,BigDecimal 表示的数值是unscaledValue × 10^(-scale)。
提供以下操作:算术、标度操作、舍入、比较、哈希算法和格式转换。
可以通过两种类型的操作来处理 BigDecimal 的标度:标度/舍入操作和小数点移动操作。标度/舍入操作(setScale 和 round)返回BigDecimal,其值近似地(或精确地)等于操作数的值,但是其标度或精度是指定的值;即:它们会增加或减少对其值具有最小影响的存储数的精度。小数点移动操作(movePointLeft 和 movePointRight)返回从操作数创建的 BigDecimal,创建的方法是按指定方向将小数点移动一个指定距离。

BigDecimal 的自然排序与 equals 方法不一致。

public class BigDecimal extends Number implementsComparable<BigDecimal>
属性:
private volatile BigInteger intVal //BigDecimal的非标度值
private int scale = 0 //BigDecimal的标度值
private volatile transient int precision = 0 //BigDecimal的精度.This field is mutable until set nonzero.
private volatile transient String stringCache = null //规范的字符表示
private static final long INFLATED = Long.MIN_VALUE //
private transient long intCompact = INFLATED
private static final int MAX_COMPACT_DIGITS = 18
private static final int MAX_BIGINT_BITS = 62
private static final long serialVersionUID = 6108874887143696463L

private static final BigDecimal zeroThroughTen[] 缓存0~10的数据
public static final BigDecimal ZERO = zeroThroughTen[0] 值为0,标度为 0。
public static final BigDecimal ONE = zeroThroughTen[1] 值为1,标度为 0。
public static final BigDecimal TEN = zeroThroughTen[10] 值为10,标度为 0。

public BigDecimal(char[] in, int offset, int len) //翻译字符数组为BigDecimal
public BigDecimal(char[] in, int offset, int len, MathContext mc) //调用this(in, offset, len);指定精度,if (mc.precision> 0) roundThis(mc)
public BigDecimal(char[] in) //调用this(in, 0, in.length)
public BigDecimal(char[] in, MathContext mc) //调用this(in,0, in.length, mc)
public BigDecimal(String val) //调用this(val.toCharArray(),0, val.length())
public BigDecimal(String val, MathContext mc) //this(val.toCharArray(), 0,val.length()); if (mc.precision > 0)roundThis(mc)

public BigDecimal(double val) //此构造方法的结果有一定的不可预知性,优先选用String参数
public BigDecimal(double val, MathContext mc) //调用this(val);if(mc.precision > 0) roundThis(mc)

public BigDecimal(BigInteger val) //将 BigInteger 转换为 BigDecimal。BigDecimal 的标度是零。
public BigDecimal(BigInteger val, MathContext mc) //将BigInteger 转换为 BigDecimal(根据上下文设置进行舍入)。BigDecimal 的标度为零。
public BigDecimal(BigInteger unscaledVal, int scale) //将 BigInteger 非标度值和 int 标度转换为 BigDecimal。BigDecimal 的值为 (unscaledVal × 10-scale)。
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) //

public BigDecimal(int val) //将int转型成BigDecimal
public BigDecimal(int val, MathContext mc) //设置精度

public BigDecimal(long val) //将long转型成BigDecimal
public BigDecimal(long val, MathContext mc) //设置精度
private BigDecimal(long val, int scale) //Trusted internal constructor
private BigDecimal(BigInteger intVal, long val, int scale) //Trusted internalconstructor

public static BigDecimal valueOf(long unscaledVal, intscale) //将 long 非标度值和 int 标度转换为 BigDecimal。
public static BigDecimal valueOf(long val) //将 long 非标度值转换为 BigDecimal。
public static BigDecimal valueOf(double val) //将 double非标度值转换为 BigDecimal。

public BigDecimal add(BigDecimal augend) //加法
public BigDecimal add(BigDecimal augend, MathContext mc) //加法,带精度

private BigDecimal[] preAlign(BigDecimal lhs, BigDecimalaugend,long padding, MathContext mc)

public BigDecimal subtract(BigDecimal subtrahend) //减法
public BigDecimal subtract(BigDecimal subtrahend, MathContext mc) //减法,带精度

public BigDecimal multiply(BigDecimal multiplicand) //乘法
public BigDecimal multiply(BigDecimal multiplicand, MathContext mc) //乘法,带精度

public BigDecimal divide(BigDecimal divisor, int scale, introundingMode) //除法
public BigDecimal divide(BigDecimal divisor, int scale, RoundingModeroundingMode) //除法
public BigDecimal divide(BigDecimal divisor, int roundingMode) //舍入模式
public BigDecimal divide(BigDecimal divisor, RoundingMode roundingMode) //舍入模式
public BigDecimal divide(BigDecimal divisor) //返回一个BigDecimal,其值为 (this / divisor),其首选标度为 (this.scale() – divisor.scale()
public BigDecimal divide(BigDecimal divisor, MathContext mc) //除法,带精度

public BigDecimal divideToIntegralValue(BigDecimal divisor)//返回整数型的除法值//返回 BigDecimal,其值为向下舍入所得商值 (this / divisor) 的整数部分。
public BigDecimal divideToIntegralValue(BigDecimal divisor, MathContext mc) //带精度

public BigDecimal remainder(BigDecimal divisor) //返回剩余部分数据//数据的值为this.subtract(this.divideToIntegralValue(divisor).multiply(divisor))
public BigDecimal remainder(BigDecimal divisor, MathContext mc) //带精度

public BigDecimal[] divideAndRemainder(BigDecimaldivisor)//除并且返回剩余值
public BigDecimal[] divideAndRemainder(BigDecimal divisor, MathContext mc) //带精度

public BigDecimal pow(int n) //N次方
public BigDecimal pow(int n, MathContext mc) //带精度

public BigDecimal abs() //绝对值
public BigDecimal abs(MathContext mc) //带精度
public BigDecimal negate() //取负
public BigDecimal negate(MathContext mc)
public BigDecimal plus() //与negate()对称
public BigDecimal plus(MathContext mc) //带精度

public int signum() //正负号函数
public int scale() //返回数的标度
public int precision() //返回数的精度
public BigInteger unscaledValue() //返回其值为此 BigDecimal 的非标度值的 BigInteger。(计算 (this *10this.scale())。)

数值的舍入方式
public final static int ROUND_UP=           0
public final static int ROUND_DOWN=         1
public final static int ROUND_CEILING =      2
public final static int ROUND_FLOOR =       3
public final static int ROUND_HALF_UP =      4
public final static int ROUND_HALF_DOWN =    5
public final static int ROUND_HALF_EVEN =    6
public final static int ROUND_UNNECESSARY =  7

public BigDecimal round(MathContext mc) //对数值进行舍入
public BigDecimal setScale(int newScale, RoundingMode roundingMode) //设置新的标度
public BigDecimal setScale(int newScale, int roundingMode) //设置新的标度
public BigDecimal setScale(int newScale) //调用setScale(newScale,ROUND_UNNECESSARY)
public BigDecimal movePointLeft(int n) //小数点左移
public BigDecimal movePointRight(int n) //小数点右移
public BigDecimal scaleByPowerOfTen(int n) //返回其数值等于(this * 10n) 的 BigDecimal。该结果的标度为 (this.scale() – n)。
public BigDecimal stripTrailingZeros() //去除尾部多余的零
public int compareTo(BigDecimal val) //比较数值的大小
public boolean equals(Object x) //判断是否相等

public BigDecimal min(BigDecimal val) //返回较小值
public BigDecimal max(BigDecimal val) //返回较大值

public int hashCode() //hashCode
public String toString() //返回字符串表示形式
public String toEngineeringString() //科学计数法
public String toPlainString() //不带指数的表示
private String getValueString(int signum, String intString, int scale) //返回digit.digit字符串的形式

public BigInteger toBigInteger()
public BigInteger toBigIntegerExact()
public long longValue()
public long longValueExact()

// These constants are only initialized if needed
/** BigInteger equal to Long.MIN_VALUE. */
private static BigInteger LONGMIN = null;
/** BigInteger equal to Long.MAX_VALUE. */
private static BigInteger LONGMAX = null;

public int intValue()
public int intValueExact()
public short shortValueExact()
public byte byteValueExact()
public float floatValue()
public double doubleValue()

public BigDecimal ulp()
private String layoutChars(boolean sci)
private static BigInteger tenToThe(int n)
private static BigInteger TENPOWERS[]
private static long longTenToThe(long val, int n)
private static long thresholds[][]
private static boolean compactLong(long val) //返回(val!= Long.MIN_VALUE)
private BigDecimal inflate()
private static void matchScale(BigDecimal[] val)

private synchronized voidreadObject(java.io.ObjectInputStream s)
private void writeObject(java.io.ObjectOutputStream s)

private int digitLength()
private static int[] ilogTable
private int intLength(int x)
private BigDecimal stripZerosToMatchScale(long preferredScale)
private int checkScale(long val)
private BigDecimal roundOp(MathContext mc)
private void roundThis(MathContext mc)
private BigDecimal doRound(MathContext mc)
private BigDecimal dropDigits(MathContext mc, int drop)
private static int longCompareTo(long x, long y)
private static void print(String name, BigDecimal bd) //内部打印格式
private BigDecimal audit() //审计

2、java.math.MathContext
该对象是封装上下文设置的不可变对象,它描述数字运算符的某些规则
precision:某个操作使用的数字个数;结果舍入到此精度
roundingMode:一个 RoundingMode 对象,该对象指定舍入使用的算法。
public final class MathContext implements Serializable

private static final int DEFAULT_DIGITS = 9;
private static final RoundingMode DEFAULT_ROUNDINGMODE = RoundingMode.HALF_UP;
private static final int MIN_DIGITS = 0 //用来表示的最少字符Maximumis Integer.MAX_VALUE
private static final long serialVersionUID = 5579720004786848255L //序列化版本号

public static final MathContext UNLIMITED =newMathContext(0, RoundingMode.HALF_UP) //具有无限精度算法所需值的MathContext 对象。
public static final MathContext DECIMAL32 =new MathContext(7,RoundingMode.HALF_EVEN) //精度设置与 IEEE 754R Decimal32 格式(即 7 个数字)匹配
public static final MathContext DECIMAL64 =new MathContext(16,RoundingMode.HALF_EVEN) //精度设置与 IEEE 754R Decimal64 格式(即 16 个数字)匹配
public static final MathContext DECIMAL128 =new MathContext(34,RoundingMode.HALF_EVEN) //精度设置与 IEEE 754R Decimal128 格式(即 34 个数字)匹配

final int precision //精度
final RoundingMode roundingMode //舍入模式

transient BigInteger roundingMax = null; //
transient BigInteger roundingMin = null; //
private static final int MAX_LOOKASIDE = 1000; //

public MathContext(int setPrecision) //设置精度,非负 int 精度设置
public MathContext(int setPrecision,RoundingMode setRoundingMode) //具有指定的精度和舍入模式。
public MathContext(String val) //与 toString() 方法生成的字符串的格式相同的输入参数

public int getPrecision() //返回精度,非负数
public RoundingMode getRoundingMode() //返回舍入模式

public boolean equals(Object x) //
public int hashCode()
public java.lang.String toString() //”precision=” + precision + ” ” +“roundingMode=” +    roundingMode.toString()

private synchronized void readObject(java.io.ObjectInputStreams)

3、java.math.RoundingMode
舍入模式
public enum RoundingMode

UP(BigDecimal.ROUND_UP)
DOWN(BigDecimal.ROUND_DOWN)
CEILING(BigDecimal.ROUND_CEILING)
FLOOR(BigDecimal.ROUND_FLOOR)
HALF_UP(BigDecimal.ROUND_HALF_UP)
HALF_DOWN(BigDecimal.ROUND_HALF_DOWN)
HALF_EVEN(BigDecimal.ROUND_HALF_EVEN)
UNNECESSARY(BigDecimal.ROUND_UNNECESSARY)

final int oldMode //舍入模式对应的代码
private RoundingMode(int oldMode) //返回与 BigDecimal 中遗留整数舍入模式常量对应的 RoundingMode 对象。
public static RoundingMode valueOf(int rm) //
public static RoundingMode valueOf(String name)
public static final RoundingMode[] values()

4、java.math.BigInteger
不可变的任意精度的整数。所有操作中,都以二进制补码形式表示 BigInteger(如 Java 的基本整数类型)。
提供Math下的方法、模算术、GCD 计算、质数测试、素数生成、位操作等
public class BigInteger extends Number implements Comparable<BigInteger>

int signum //符号位
int[] mag //The magnitude of this BigInteger, in big-endian order
private int bitCount =  -1 //The bitCount of this BigInteger
private int bitLength = -1 //The bitLength of this BigInteger
private int lowestSetBit = -2 //The lowest set bit of this BigInteger
private int firstNonzeroByteNum = -2 //The index of the lowest-order byte inthe magnitude of this BigInteger
private int firstNonzeroIntNum = -2 //The index of the lowest-order int in themagnitude of this BigInteger
private final static long LONG_MASK = 0xffffffffL //无符号数的掩码

public BigInteger(byte[] val) //将包含BigInteger 的二进制补码表示形式的 byte 数组转换为 BigInteger。
private BigInteger(int[] val)
public BigInteger(int signum, byte[] magnitude) //将BigInteger 的符号-数量表示形式转换为BigInteger。
private BigInteger(int signum, int[] magnitude)
public BigInteger(String val, int radix) //将指定基数的BigInteger 的字符串表示形式转换为 BigInteger。

private static long bitsPerDigit[] = { 0, 0,
1024, 1624, 2048, 2378, 2648, 2875, 3072, 3247, 3402, 3543, 3672,
3790, 3899, 4001, 4096, 4186, 4271, 4350, 4426, 4498, 4567, 4633,
4696, 4756, 4814, 4870, 4923, 4975, 5025, 5074, 5120, 5166, 5210,
5253, 5295}

private static void destructiveMulAdd(int[] x, int y, intz)
public BigInteger(String val) //将 BigInteger 的十进制字符串表示形式转换为 BigInteger。
public BigInteger(int numBits, Random rnd) //构造一个随机生成的BigInteger,它是在 0 到 (2numBits –1)(包括)范围内均匀分布的值。
private static byte[] randomBits(int numBits, Random rnd)
public BigInteger(int bitLength, int certainty, Random rnd) //构造一个随机生成的正 BigInteger,它可能是一个具有指定 bitLength 的素数。

private static final int SMALL_PRIME_THRESHOLD = 95
private static final int DEFAULT_PRIME_CERTAINTY = 100

public static BigInteger probablePrime(int bitLength,Random rnd) //返回有可能是素数的、具有指定长度的正 BigInteger。
private static BigInteger smallPrime(int bitLength, int certainty, Random rnd)

private static final BigInteger SMALL_PRIME_PRODUCT =valueOf(3L*5*7*11*13*17*19*23*29*31*37*41)

private static BigInteger largePrime(int bitLength, intcertainty, Random rnd)
public BigInteger nextProbablePrime()//返回大于此 BigInteger的可能为素数的第一个整数。
boolean primeToCertainty(int certainty, Random random)
private boolean passesLucasLehmer()
private static int jacobiSymbol(int p, BigInteger n)
private static BigInteger lucasLehmerSequence(int z, BigInteger k, BigIntegern)
private static volatile Random staticRandom
private static Random getSecureRandom()
private boolean passesMillerRabin(int iterations, Random rnd)

private BigInteger(int[] magnitude, int signum)
private BigInteger(byte[] magnitude, int signum)
public static BigInteger valueOf(long val) //返回其值等于指定long 的值的 BigInteger。
private BigInteger(long val)
private static BigInteger valueOf(int val[])

private final static int MAX_CONSTANT = 16;
private static BigInteger posConst[] = new BigInteger[MAX_CONSTANT+1];
private static BigInteger negConst[] = new BigInteger[MAX_CONSTANT+1];
static {//Initialize static constant array when class is loaded.
for (int i = 1; i <= MAX_CONSTANT; i++) {
int[] magnitude = new int[1];
magnitude[0] = (int) i;
posConst[i] = new BigInteger(magnitude,  1);
negConst[i] = new BigInteger(magnitude, -1);
}
}

public static final BigInteger ZERO = new BigInteger(newint[0], 0) //0
public static final BigInteger ONE = valueOf(1) //1
private static final BigInteger TWO = valueOf(2) //2
public static final BigInteger TEN = valueOf(10) //10

public BigInteger add(BigInteger val) //加
private static int[] add(int[] x, int[] y) //Adds the contents of the intarrays x and y.

public BigInteger subtract(BigInteger val) //减
private static int[] subtract(int[] big, int[] little)

public BigInteger multiply(BigInteger val)
private int[] multiplyToLen(int[] x, int xlen, int[] y, int ylen, int[] z)//Multiplies int arrays x and y to the specified lengths places the result intoz.
private BigInteger square()
private static final int[] squareToLen(int[] x, int len, int[] z)
public BigInteger divide(BigInteger val) //商
public BigInteger[] divideAndRemainder(BigInteger val) //商、余数
public BigInteger remainder(BigInteger val) //余数
public BigInteger pow(int exponent) //次方
public BigInteger gcd(BigInteger val) //最大公约数

private static int[] leftShift(int[] a, int len, intn)  //左移<<
static void primitiveRightShift(int[] a, int len, int n) //右移>>>
static void primitiveLeftShift(int[] a, int len, int n)
private static int bitLength(int[] val, int len)

public BigInteger abs() //绝对值
public BigInteger negate() //相反数
public int signum() //符号
public BigInteger mod(BigInteger m) //取余数
public BigInteger modPow(BigInteger exponent, BigInteger m) //指数模m

static int[] bnExpModThreshTable = {7, 25, 81, 241, 673,1793,Integer.MAX_VALUE}
private BigInteger oddModPow(BigInteger y, BigInteger z) //whose value is x tothe power of y mod z
private static int[] montReduce(int[] n, int[] mod, int mlen, int inv)//Montgomery reduce n, modulo mod.
private static int intArrayCmpToLen(int[] arg1, int[] arg2, int len) //Returns-1, 0 or +1
private static int subN(int[] a, int[] b, int len) //Subtracts two numbers ofsame length
static int mulAdd(int[] out, int[] in, int offset, int len, int k) //Multiplyan array by one word k and add to result
static int addOne(int[] a, int offset, int mlen, int carry) //Add one word tothe number a mlen words into a.
private BigInteger modPow2(BigInteger exponent, int p) //(this ** exponent) mod(2**p)
private BigInteger mod2(int p) //this mod(2**p)
public BigInteger modInverse(BigInteger m) //(this-1 mod m)
public BigInteger shiftLeft(int n) //左移
public BigInteger shiftRight(int n) //右移

public BigInteger and(BigInteger val) //与this & val
public BigInteger or(BigInteger val) //或this | val
public BigInteger xor(BigInteger val) //异或this ^ val
public BigInteger not() //非 ~this
public BigInteger andNot(BigInteger val) //与非 this&~ val
public boolean testBit(int n) //当且仅当设置了指定的位时,返回 true。
public BigInteger setBit(int n) //返回其值与设置了指定位的此BigInteger 等效的 BigInteger。
public BigInteger clearBit(int n) //返回其值与清除了指定位的此BigInteger 等效的 BigInteger。
public BigInteger flipBit(int n) //this ^ (1<<n)
public int getLowestSetBit() //此 BigInteger 最右端(最低位)1 比特的索引
public int bitLength() //此 BigInteger 的最小的二进制补码表示形式的位数

static int bitLen(int w)
final static byte trailingZeroTable[]

public int bitCount() //二进制补码表示形式中与符号不同的位的数量。
static int bitCnt(int val)
static int trailingZeroCnt(int val)

public boolean isProbablePrime(int certainty) // BigInteger可能为素数
public int compareTo(BigInteger val) //比较
private static int intArrayCmp(int[] arg1, int[] arg2)
public boolean equals(Object x) //相等

public BigInteger min(BigInteger val) //取小
public BigInteger max(BigInteger val) //取大
public int hashCode() //hash值
public String toString(int radix) //转换成进制
public String toString() //转换成10进制
public byte[] toByteArray() //字节数组

public int intValue()
public long longValue()
public float floatValue()
public double doubleValue()

private static int[] stripLeadingZeroInts(int val[])
private static int[] trustedStripLeadingZeroInts(int val[])
private static int[] stripLeadingZeroBytes(byte a[])
private static int[] makePositive(byte a[])
private static int[] makePositive(int a[])

private static int digitsPerLong[]
private static BigInteger longRadix[]
private static int digitsPerInt[]
private static int intRadix[]

private int intLength()
private int signBit()
private int signInt()
private int getInt(int n)
private int firstNonzeroIntNum()

private static final long serialVersionUID =-8287574255936472291L

private static final ObjectStreamField[]serialPersistentFields
private void readObject(java.io.ObjectInputStream s)
private void writeObject(ObjectOutputStream s)
private byte[] magSerializedForm()

5、java.math.BitSieve
字节过滤类,
class BitSieve
private long bits[] //存储bit过滤Storesthe bits in this bitSieve.
private int length //Length is how many bits this sieve holds.
private static BitSieve smallSieve = new BitSieve() //A small sieve used tofilter out multiples of small primes in a search sieve.

private BitSieve()
BitSieve(BigInteger base, int searchLen) //Construct a bit sieve of searchLenbits used for finding prime number candidates.

private static int unitIndex(int bitIndex) //Given a bitindex return unit index containing it.
private static long bit(int bitIndex) //Return a unit that masks the specifiedbit in its unit.

private boolean get(int bitIndex) //Get the value of thebit at the specified index.
private void set(int bitIndex) //Set the bit at the specified index.
private int sieveSearch(int limit,  int start) //returns the index of thefirst clear bit in the search array
private void sieveSingle(int limit, int start, int step) //Sieve a single setof multiples out of the sieve.
BigInteger retrieve(BigInteger initValue, int certainty, java.util.Randomrandom) //Test probable primes in the sieve and return successful candidates.

6、java.math.MutableBigInteger
可变的BigInteger
class MutableBigInteger

int[] value
int intLen
int offset = 0
private final static long LONG_MASK = 0xffffffffL

MutableBigInteger()
MutableBigInteger(int val)
MutableBigInteger(int[] val, int len)
MutableBigInteger(int[] val)
MutableBigInteger(BigInteger b)
MutableBigInteger(MutableBigInteger val)

void clear()
void reset()

final int compare(MutableBigInteger b) //比较
private final int getLowestSetBit()
private final int getInt(int index)
private final long getLong(int index)
final void normalize()
private final void ensureCapacity(int len)

int[] toIntArray()
void setInt(int index, int val)
void setValue(int[] val, int length)
void copyValue(MutableBigInteger val)
void copyValue(int[] val)

boolean isOne()
boolean isZero()
boolean isEven()
boolean isOdd()
boolean isNormal()

public String toString()
void rightShift(int n)
void leftShift(int n)

private int divadd(int[] a, int[] result, int offset)
private int mulsub(int[] q, int[] a, int x, int len, int offset)

private final void primitiveRightShift(int n)
private final void primitiveLeftShift(int n)

void add(MutableBigInteger addend)
int subtract(MutableBigInteger b)
private int difference(MutableBigInteger b)
void multiply(MutableBigInteger y, MutableBigInteger z)
void mul(int y, MutableBigInteger z)
void divideOneWord(int divisor, MutableBigInteger quotient)
void divide(MutableBigInteger b,MutableBigInteger quotient, MutableBigIntegerrem)
private boolean unsignedLongCompare(long one, long two)
private void divWord(int[] result, long n, int d)

MutableBigInteger hybridGCD(MutableBigInteger b)//Calculate GCD of this and b.
private MutableBigInteger binaryGCD(MutableBigInteger v) //Calculate GCD ofthis and v.
static int binaryGcd(int a, int b) //Calculate GCD of a and b interpreted asunsigned integers.

MutableBigInteger mutableModInverse(MutableBigInteger p)//the modInverse of this mod p.
MutableBigInteger modInverseMP2(int k) // inverse of this mod 2^k
static int inverseMod32(int val) //inverse of val mod 2^32
static MutableBigInteger modInverseBP2(MutableBigInteger mod, int k) //inverseof 2^k mod mod
private MutableBigInteger modInverse(MutableBigInteger mod)
static MutableBigInteger fixup(MutableBigInteger c, MutableBigInteger p,int k)//X = C * 2^(-k) (mod P)
MutableBigInteger euclidModInverse(int k) //mod a modulus that is a power of 2

7、java.math.SignedMutableBigInteger
有符号的可变的BigInteger
class SignedMutableBigInteger extends MutableBigInteger

int sign = 1
SignedMutableBigInteger()
SignedMutableBigInteger(int val)
SignedMutableBigInteger(MutableBigInteger val)

方法:
void signedAdd(SignedMutableBigInteger addend) //加
void signedAdd(MutableBigInteger addend) //加

void signedSubtract(SignedMutableBigInteger addend) //减
void signedSubtract(MutableBigInteger addend) //减

public String toString()

Java jdk源代码的Math包相关推荐

  1. Java.math包中常用的类

    Java.math包 Java.math.BigDecimal类 Java.math.BigInteger类实例 Java.math.MathContext类实例

  2. Java JDK 11:现在可以使用所有新功能

    为什么80%的码农都做不了架构师?>>>    删除了CORBA,Java EE和JavaFX支持,但添加了十几个主要新功能 目录 哪里可以下载JDK 11 Java 11 JDK中 ...

  3. 一篇文章了解新发布的Java JDK 11

    Java JDK 11删除了CORBA,Java EE和JavaFX支持,但添加了十几个主要新功能. Java Development Kit(JDK)11现已普遍可用,可供生产使用,提高了工作效率, ...

  4. JAVA JDK 源码学习

    JAVA JDK 源码学习 ,以1.8为例,按照下面图片顺序依次学习: applet ,awt,beans,io,lang,math,net,nio,rmi,security,sql,text,tim ...

  5. java TreeMap 源代码分析 平衡二叉树

    TreeMap 的实现就是红黑树数据结构,也就说是一棵自平衡的排序二叉树,这样就可以保证当需要快速检索指定节点. TreeSet 和 TreeMap 的关系 为了让大家了解 TreeMap 和 Tre ...

  6. 通过分析 JDK 源代码研究 Hash 存储机制

    http://www.ibm.com/developerworks/cn/java/j-lo-hash/ 通过分析 JDK 源代码研究 Hash 存储机制 HashMap 和 HashSet 是 Ja ...

  7. (转)Linux(Centos)之安装Java JDK及注意事项

    场景:天下事有难易乎?为之,则难者亦易矣:不为,则易者亦难矣.人之为学有难易乎?学之,则难者亦易矣:不学,则易者亦难矣. 1 准备工作 下面配置jdk的方式在具有root权限时候能够执行.如果没有ro ...

  8. 编译JDK源代码【转】

    用Eclipse Debug,当跟踪进jdk api里时(比如javax.swing包里的类),无法查看某些local filed的值.这是因为jdk里的代码在打包时删除了一些用于调试的信息,以减小安 ...

  9. JAVA:JDK目录结构和文件作用介绍

    要想深入了解Java必须对JDK的组成, 本文对JDK6里的目录做了基本的介绍,主要还是讲解 了下JDK里的各种可执行程序或工具的用途 Java(TM) 有两个平台 JRE 运行平台,包括Java虚拟 ...

最新文章

  1. 18岁辍学,22岁进谷歌和Jeff Dean谈笑风生,这样的我究竟需不需要本科文凭?
  2. 打开word或者office程序报错:Microsoft Visual C++ Runtime Library. Runtime Error!
  3. jQuery+php+ajax实现无刷新上传文件功能
  4. jQuery自定义漂亮的下拉框插件8种效果演示
  5. Solr管理页面 上
  6. 7 操作系统第二章 进程管理 进程同步与互斥
  7. AnnotationUtils
  8. 如何提高matlab的运算速度慢,如何提高MATLAB的运算速度
  9. python安装matplotlib绘图库
  10. 设计模式之GOF23观察者模式
  11. KeyShot中该怎么添加反射地平面
  12. 大型高端OA协同办公系统源码分享
  13. 木子-数据库-oracle如何创建一个新的实例
  14. Scout - 可扩展的服务器和应用监控服务
  15. 中蜂几月份自然分蜂_中蜂养殖,如何给蜜蜂分蜂?时间是关键
  16. java计算机毕业设计淮安城市开放大学实习实训管理系统源码+mysql数据库+系统+lw文档+部署
  17. 用户登录 验证数据库
  18. 创建pdf java 字体_如何使用自定义字体从servlet使用iText XMLWorker创建PDF?
  19. 白菜个人导航页2.0
  20. 关于android的webview打开淘宝天猫链接问题

热门文章

  1. ZigBee中的技术问题以及解决方案
  2. 按图搜索淘宝商品-item_search_img (拍立淘)
  3. php机房图形资产管理系统,机房资产管理系统(CMDB)
  4. 中国教育“善意的谎言”与恶果
  5. 让你的查询支持中文拼音码模糊查询。
  6. 第十六章:开发工具-compileall:字节编译源文件-编译单个文件
  7. 图片太大不要慌,简单的调整图片大小
  8. 电脑桌面图标不能正常显示解决办法
  9. ps可以去视频水印h吗
  10. 比赛即实战!中国软件杯发布全新产业创新赛项,校企可联合参赛