JAVA中大数经常使用的函数
声明为 BigInteger 的 java.math 中的字段
static BigInteger BigInteger. ONE
BigInteger 的常量 1。
static BigInteger BigInteger. TEN
BigInteger 的常量 10。
static BigInteger BigInteger. ZERO
BigInteger 的常量 0。 返回 BigInteger 的 java.math 中的方法
BigInteger BigInteger. abs ()
返回其值是此 BigInteger 的绝对值的 BigInteger。
BigInteger BigInteger. add (BigInteger val)
返回其值为 (this + val) 的 BigInteger。
BigInteger BigInteger. and (BigInteger val)
返回其值为 (this & val) 的 BigInteger。
BigInteger BigInteger. andNot (BigInteger val)
返回其值为 (this & ~val) 的 BigInteger。 BigInteger BigInteger. clearBit (int n)
返回其值与清除了指定位的此 BigInteger 等效的 BigInteger。 BigInteger BigInteger. divide (BigInteger val)
返回其值为 (this / val) 的 BigInteger。 BigInteger [] BigInteger. divideAndRemainder (BigInteger val)
返回包括 (this / val) 后跟 (this % val) 的两个 BigInteger 的数组。
BigInteger BigInteger. flipBit (int n)
返回其值与对此 BigInteger 进行指定位翻转后的值等效的 BigInteger。 BigInteger BigInteger. gcd (BigInteger val)
返回一个 BigInteger。其值是 abs(this) 和 abs(val) 的最大公约数。
BigInteger BigInteger. max (BigInteger val)
返回此 BigInteger 和 val 的最大值。
BigInteger BigInteger. min (BigInteger val)
返回此 BigInteger 和 val 的最小值。
BigInteger BigInteger. mod (BigInteger m)
返回其值为 (this mod m ) 的 BigInteger。
BigInteger BigInteger. modInverse (BigInteger m)
返回其值为 (this-1 mod m) 的 BigInteger。
BigInteger BigInteger. modPow (BigInteger exponent, BigInteger m)
返回其值为 (thisexponent mod m) 的 BigInteger。 BigInteger BigInteger. multiply (BigInteger val)
返回其值为 (this * val) 的 BigInteger。
BigInteger BigInteger. negate ()
返回其值是 (-this) 的 BigInteger。 BigInteger BigInteger. nextProbablePrime ()
返回大于此 BigInteger 的可能为素数的第一个整数。
BigInteger BigInteger. not ()
返回其值为 (~this) 的 BigInteger。 BigInteger BigInteger. or (BigInteger val)
返回其值为 (this | val) 的 BigInteger。
BigInteger BigInteger. pow (int exponent)
返回其值为 (thisexponent ) 的 BigInteger。
static BigInteger BigInteger. probablePrime (int bitLength, Random rnd)
返回有可能是素数的、具有指定长度的正 BigInteger。
BigInteger BigInteger. remainder (BigInteger val)
返回其值为 (this % val) 的 BigInteger。
BigInteger BigInteger. setBit (int n)
返回其值与设置了指定位的此 BigInteger 等效的 BigInteger。 BigInteger BigInteger. shiftLeft (int n)
返回其值为 (this << n) 的 BigInteger。
BigInteger BigInteger. shiftRight (int n)
返回其值为 (this >> n) 的 BigInteger。
BigInteger BigInteger. subtract (BigInteger val)
返回其值为 (this - val) 的 BigInteger。
BigInteger BigDecimal. toBigInteger ()
将此 BigDecimal 转换为 BigInteger 。
BigInteger BigDecimal. toBigIntegerExact ()
将此 BigDecimal 转换为 BigInteger ,以检查丢失的信息。
BigInteger BigDecimal. unscaledValue ()
返回其值为此 BigDecimal 的非标度值 的 BigInteger 。
static BigInteger BigInteger. valueOf (long val)
返回其值等于指定 long 的值的 BigInteger。
BigInteger BigInteger. xor (BigInteger val)
返回其值为 (this ^ val) 的 BigInteger。
參数类型为 BigInteger 的 java.math 中的方法
BigInteger BigInteger. add (BigInteger val)
返回其值为 (this + val) 的 BigInteger。
BigInteger BigInteger. and (BigInteger val)
返回其值为 (this & val) 的 BigInteger。
BigInteger BigInteger. andNot (BigInteger val)
返回其值为 (this & ~val) 的 BigInteger。
int BigInteger. compareTo (BigInteger val)
将此 BigInteger 与指定的 BigInteger 进行比較。
BigInteger BigInteger. divide (BigInteger val)
返回其值为 (this / val) 的 BigInteger。 BigInteger [] BigInteger. divideAndRemainder (BigInteger val)
返回包括 (this / val) 后跟 (this % val) 的两个 BigInteger 的数组。
BigInteger BigInteger. gcd (BigInteger val)
返回一个 BigInteger。其值是 abs(this) 和 abs(val) 的最大公约数。 BigInteger BigInteger. max (BigInteger val)
返回此 BigInteger 和 val 的最大值。
BigInteger BigInteger. min (BigInteger val)
返回此 BigInteger 和 val 的最小值。
BigInteger BigInteger. mod (BigInteger m)
返回其值为 (this mod m ) 的 BigInteger。 BigInteger BigInteger. modInverse (BigInteger m)
返回其值为 (this-1 mod m) 的 BigInteger。
BigInteger BigInteger. modPow (BigInteger exponent, BigInteger m)
返回其值为 (thisexponent mod m) 的 BigInteger。
BigInteger BigInteger. multiply (BigInteger val)
返回其值为 (this * val) 的 BigInteger。 BigInteger BigInteger. or (BigInteger val)
返回其值为 (this | val) 的 BigInteger。
BigInteger BigInteger. remainder (BigInteger val)
返回其值为 (this % val) 的 BigInteger。
BigInteger BigInteger. subtract (BigInteger val)
返回其值为 (this - val) 的 BigInteger。
BigInteger BigInteger. xor (BigInteger val)
返回其值为 (this ^ val) 的 BigInteger。 參数类型为 BigInteger 的 java.math 中的构造方法
BigDecimal (BigInteger val)
将 BigInteger 转换为 BigDecimal 。
BigDecimal (BigInteger unscaledVal, int scale)
将 BigInteger 非标度值和 int 标度转换为 BigDecimal 。 BigDecimal (BigInteger unscaledVal, int scale, MathContext mc)
将 BigInteger 非标度值和 int 标度转换为 BigDecimal (依据上下文设置进行舍入)。
BigDecimal (BigInteger val, MathContext mc)
将 BigInteger 转换为 BigDecimal (依据上下文设置进行舍入)。 java.util 中 BigInteger 的使用 返回 BigInteger 的 java.util 中的方法
BigInteger Scanner. nextBigInteger ()
将输入信息的下一个标记扫描为一个 BigInteger 。 BigInteger Scanner. nextBigInteger (int radix)
将输入信息的下一个标记扫描为一个 BigInteger 。 java.math 中 BigDecimal 的使用
声明为 BigDecimal 的 java.math 中的字段
static BigDecimal BigDecimal. ONE
值为 1,标度为 0。 static BigDecimal BigDecimal. TEN
值为 10,标度为 0。
static BigDecimal BigDecimal. ZERO
值为 0,标度为 0。 返回 BigDecimal 的 java.math 中的方法
BigDecimal BigDecimal. abs ()
返回 BigDecimal ,其值为此 BigDecimal 的绝对值,其标度为 this.scale() 。 BigDecimal BigDecimal. abs (MathContext mc)
返回其值为此 BigDecimal 绝对值的 BigDecimal (依据上下文设置进行舍入)。
BigDecimal BigDecimal. add (BigDecimal augend)
返回一个 BigDecimal ,其值为 (this + augend) ,其标度为 max(this.scale(), augend.scale()) 。 BigDecimal BigDecimal. add (BigDecimal augend, MathContext mc)
返回其值为 (this + augend) 的 BigDecimal (依据上下文设置进行舍入)。
BigDecimal BigDecimal. divide (BigDecimal divisor)
返回一个 BigDecimal ,其值为 (this / divisor) ,其首选标度为 (this.scale() - divisor.scale()) ;假设无法表示准确的商值(由于它有无穷的十进制扩展),则抛出 ArithmeticException 。
BigDecimal BigDecimal. divide (BigDecimal divisor, int roundingMode)
返回一个 BigDecimal ,其值为 (this / divisor) ,其标度为 this.scale() 。
BigDecimal BigDecimal. divide (BigDecimal divisor, int scale, int roundingMode)
返回一个 BigDecimal 。其值为 (this / divisor) ,其标度为指定标度。 BigDecimal BigDecimal. divide (BigDecimal divisor, int scale, RoundingMode roundingMode)
返回一个 BigDecimal ,其值为 (this / divisor) ,其标度为指定标度。
BigDecimal BigDecimal. divide (BigDecimal divisor, MathContext mc)
返回其值为 (this / divisor) 的 BigDecimal (依据上下文设置进行舍入)。
BigDecimal BigDecimal. divide (BigDecimal divisor, RoundingMode roundingMode)
返回一个 BigDecimal ,其值为 (this / divisor) 。其标度为 this.scale() 。
BigDecimal [] BigDecimal. divideAndRemainder (BigDecimal divisor)
返回由两个元素组成的 BigDecimal 数组,该数组包括 divideToIntegralValue 的结果,后跟对两个操作数计算所得到的 remainder 。 BigDecimal [] BigDecimal. divideAndRemainder (BigDecimal divisor, MathContext mc)
返回由两个元素组成的 BigDecimal 数组,该数组包括 divideToIntegralValue 的结果,后跟依据上下文设置对两个操作数进行舍入计算所得到的 remainder 的结果。 BigDecimal BigDecimal. divideToIntegralValue (BigDecimal divisor)
返回 BigDecimal 。其值为向下舍入所得商值 (this / divisor) 的整数部分。
BigDecimal BigDecimal. divideToIntegralValue (BigDecimal divisor, MathContext mc)
返回 BigDecimal 。其值为 (this / divisor) 的整数部分。 BigDecimal BigDecimal. max (BigDecimal val)
返回此 BigDecimal 和 val 的最大值。
BigDecimal BigDecimal. min (BigDecimal val)
返回此 BigDecimal 和 val 的最小值。 BigDecimal BigDecimal. movePointLeft (int n)
返回一个 BigDecimal ,它等效于将该值的小数点向左移动 n 位。
BigDecimal BigDecimal. movePointRight (int n)
返回一个 BigDecimal 。它等效于将该值的小数点向右移动 n 位。 BigDecimal BigDecimal. multiply (BigDecimal multiplicand)
返回一个 BigDecimal ,其值为 (this × multiplicand) ,其标度为 (this.scale() + multiplicand.scale()) 。
BigDecimal BigDecimal. multiply (BigDecimal multiplicand, MathContext mc)
返回其值为 (this × multiplicand) 的 BigDecimal (依据上下文设置进行舍入)。 BigDecimal BigDecimal. negate ()
返回 BigDecimal 。其值为 (-this) ,其标度为 this.scale() 。
BigDecimal BigDecimal. negate (MathContext mc)
返回其值为 (-this) 的 BigDecimal (依据上下文设置进行舍入)。 BigDecimal BigDecimal. plus ()
返回 BigDecimal ,其值为 (+this) ,其标度为 this.scale() 。
BigDecimal BigDecimal. plus (MathContext mc)
返回其值为 (+this) 的 BigDecimal (依据上下文设置进行舍入)。
BigDecimal BigDecimal. pow (int n)
返回其值为 (thisn ) 的 BigDecimal 。准确计算该幂,使其具有无限精度。 BigDecimal BigDecimal. pow (int n, MathContext mc)
返回其值为 (thisn ) 的 BigDecimal 。 BigDecimal BigDecimal. remainder (BigDecimal divisor)
返回其值为 (this % divisor) 的 BigDecimal 。
BigDecimal BigDecimal. remainder (BigDecimal divisor, MathContext mc)
返回其值为 (this % divisor) 的 BigDecimal (依据上下文设置进行舍入)。
BigDecimal BigDecimal. round (MathContext mc)
返回依据 MathContext 设置进行舍入后的 BigDecimal 。
BigDecimal BigDecimal. scaleByPowerOfTen (int n)
返回其数值等于 (this * 10n ) 的 BigDecimal。
BigDecimal BigDecimal. setScale (int newScale)
返回一个 BigDecimal ,其标度为指定值。其值在数值上等于此 BigDecimal 的值。
BigDecimal BigDecimal. setScale (int newScale, int roundingMode)
返回一个 BigDecimal ,其标度为指定值,其非标度值通过此 BigDecimal 的非标度值乘以或除以十的适当次幂来确定。以维护其总值。
BigDecimal BigDecimal. setScale (int newScale, RoundingMode roundingMode)
返回 BigDecimal ,其标度为指定值,其非标度值通过此 BigDecimal 的非标度值乘以或除以十的适当次幂来确定。以维护其总值。
BigDecimal BigDecimal. stripTrailingZeros ()
返回数值上等于此小数。但从该表示形式移除全部尾部零的 BigDecimal 。
BigDecimal BigDecimal. subtract (BigDecimal subtrahend)
返回一个 BigDecimal ,其值为 (this - subtrahend) 。其标度为 max(this.scale(), subtrahend.scale()) 。
BigDecimal BigDecimal. subtract (BigDecimal subtrahend, MathContext mc)
返回其值为 (this - subtrahend) 的 BigDecimal (依据上下文设置进行舍入)。
BigDecimal BigDecimal. ulp ()
返回此 BigDecimal 的 ulp(最后一位的单位)的大小。 static BigDecimal BigDecimal. valueOf (double val)
使用 Double.toString(double) 方法提供的 double 规范的字符串表示形式将 double 转换为 BigDecimal 。 static BigDecimal BigDecimal. valueOf (long val)
将 long 值转换为具有零标度的 BigDecimal 。
static BigDecimal BigDecimal. valueOf (long unscaledVal, int scale)
将 long 非标度值和 int 标度转换为 BigDecimal 。
參数类型为 BigDecimal 的 java.math 中的方法
BigDecimal BigDecimal. add (BigDecimal augend)
返回一个 BigDecimal ,其值为 (this + augend) ,其标度为 max(this.scale(), augend.scale()) 。
BigDecimal BigDecimal. add (BigDecimal augend, MathContext mc)
返回其值为 (this + augend) 的 BigDecimal (依据上下文设置进行舍入)。 int BigDecimal. compareTo (BigDecimal val)
将此 BigDecimal 与指定的 BigDecimal 比較。 BigDecimal BigDecimal. divide (BigDecimal divisor)
返回一个 BigDecimal ,其值为 (this / divisor) 。其首选标度为 (this.scale() - divisor.scale()) ;假设无法表示准确的商值(由于它有无穷的十进制扩展)。则抛出 ArithmeticException 。
BigDecimal BigDecimal. divide (BigDecimal divisor, int roundingMode)
返回一个 BigDecimal ,其值为 (this / divisor) ,其标度为 this.scale() 。
BigDecimal BigDecimal. divide (BigDecimal divisor, int scale, int roundingMode)
返回一个 BigDecimal ,其值为 (this / divisor) ,其标度为指定标度。 BigDecimal BigDecimal. divide (BigDecimal divisor, int scale, RoundingMode roundingMode)
返回一个 BigDecimal 。其值为 (this / divisor) 。其标度为指定标度。
BigDecimal BigDecimal. divide (BigDecimal divisor, MathContext mc)
返回其值为 (this / divisor) 的 BigDecimal (依据上下文设置进行舍入)。
BigDecimal BigDecimal. divide (BigDecimal divisor, RoundingMode roundingMode)
返回一个 BigDecimal ,其值为 (this / divisor) ,其标度为 this.scale() 。 BigDecimal [] BigDecimal. divideAndRemainder (BigDecimal divisor)
返回由两个元素组成的 BigDecimal 数组,该数组包括 divideToIntegralValue 的结果,后跟对两个操作数计算所得到的 remainder 。
BigDecimal [] BigDecimal. divideAndRemainder (BigDecimal divisor, MathContext mc)
返回由两个元素组成的 BigDecimal 数组,该数组包括 divideToIntegralValue 的结果,后跟依据上下文设置对两个操作数进行舍入计算所得到的 remainder 的结果。 BigDecimal BigDecimal. divideToIntegralValue (BigDecimal divisor)
返回 BigDecimal ,其值为向下舍入所得商值 (this / divisor) 的整数部分。
BigDecimal BigDecimal. divideToIntegralValue (BigDecimal divisor, MathContext mc)
返回 BigDecimal ,其值为 (this / divisor) 的整数部分。 BigDecimal BigDecimal. max (BigDecimal val)
返回此 BigDecimal 和 val 的最大值。
BigDecimal BigDecimal. min (BigDecimal val)
返回此 BigDecimal 和 val 的最小值。 BigDecimal BigDecimal. multiply (BigDecimal multiplicand)
返回一个 BigDecimal 。其值为 (this × multiplicand) 。其标度为 (this.scale() + multiplicand.scale()) 。
BigDecimal BigDecimal. multiply (BigDecimal multiplicand, MathContext mc)
返回其值为 (this × multiplicand) 的 BigDecimal (依据上下文设置进行舍入)。 BigDecimal BigDecimal. remainder (BigDecimal divisor)
返回其值为 (this % divisor) 的 BigDecimal 。
BigDecimal BigDecimal. remainder (BigDecimal divisor, MathContext mc)
返回其值为 (this % divisor) 的 BigDecimal (依据上下文设置进行舍入)。 BigDecimal BigDecimal. subtract (BigDecimal subtrahend)
返回一个 BigDecimal ,其值为 (this - subtrahend) ,其标度为 max(this.scale(), subtrahend.scale()) 。
BigDecimal BigDecimal. subtract (BigDecimal subtrahend, MathContext mc)
返回其值为 (this - subtrahend) 的 BigDecimal (依据上下文设置进行舍入)。 java.util 中 BigDecimal 的使用 返回 BigDecimal 的 java.util 中的方法
BigDecimal Scanner. nextBigDecimal ()
将输入信息的下一个标记扫描为一个 BigDecimal 。
JAVA中大数经常使用的函数的更多相关文章
- Java中的Random()函数-----转载
Java中的Random()函数 (2013-01-24 21:01:04) 转载▼ 标签: java random 随机函数 杂谈 分类: Java 今天在做Java练习的时候注意到了Java里面的 ...
- Java中math类的常用函数
Java中math类的常用函数 在 Java 中 Math 类封装了常用的数学运算,提供了基本的数学操作,如指数.对数.平方根和三角函数等 只要在源文件的顶部加上下面这行代码就不必在数学方法名和常量名 ...
- Java中的Random()函数
今天在做Java练习的时候注意到了Java里面的一个随机函数——Random,刚开始只是知道这个函数具有随机取值的作用,于是上网搜索了资料一番,做了一下一些关于Random函数的总结: Java中 ...
- Java中的Random()函数 【转载】
今天在做Java练习的时候注意到了Java里面的一个随机函数——Random,刚开始只是知道这个函数具有随机取值的作用,于是上网搜索了资料一番,做了一下一些关于Random函数的总结: J ...
- java中的==操作符和equals函数
基本规则 “==”操作符的使用需要分成两种情况 判值类型相等 这一点很好理解,两个值类型代表的数值相等,则“==”表达式返回true “==”可以用与不同值类型的比较,语言会自动进行类型转换 判引用类 ...
- Java中大数的使用与Java入门(NCPC-Intergalactic Bidding)
引入 前几天参加湖南多校的比赛,其中有这样一道题,需要使用高精度,同时需要排序,如果用c++实现的话,重载运算符很麻烦,于是直接学习了一发怎样用Java写大数,同时也算是学习Java基本常识了 题目 ...
- java中大数类的学习
java中提供了大数类BigInteger和BigDecimal分别表示大整数类和大浮点数类,这两个类都在java.math.*包中,因此每次必须在开头处引用该包. 一.BigInteger构造函数: ...
- java中String字符串的替换函数:replace与replaceAll的区别
例如有如下x的字符串 String x = "[kllkklk\\kk\\kllkk]";要将里面的“kk”替换为++,可以使用两种方法得到相同的结果 replace(CharSe ...
- java 中的SimpleDateFormat、Date函数以及字符串和Date类型互转
SimpleDateFormat是一个以与语言环境有关的方式来格式化和解析日期的具体类.它允许进行格式化(日期 -> 文本).解析(文本 -> 日期)和规范化. SimpleDateFor ...
随机推荐
- 【转】Unity3D研究院之两种方式播放游戏视频
http://www.xuanyusong.com/archives/1019 Unity3D中播放游戏视频的方式有两种,第一种是在游戏对象中播放,就好比在游戏世界中创建一个Plane面对象,摄像 ...
- P2412 查单词
题目背景 滚粗了的HansBug在收拾旧英语书,然而他发现了什么奇妙的东西. 题目描述 udp2.T3如果遇到相同的字符串,输出后面的 蒟蒻HansBug在一本英语书里面找到了一个单词表,包含N个单词 ...
- canvas图片跨域问题
canvas的drawImage使用跨域图片时候,会报错,解决方法如下: 1. 使用base64替换跨域图片 如果图片不大,且只有几张,可以使用base64,来代替跨域引用图片. 2. 设置image ...
- [USACO Section 5.3]量取牛奶 Milk Measuring (动态规划,背包$dp$)
题目链接 Solution 完全背包 \(dp\) , 同时再加一个数组 \(v[i][j]\) 记录当总和为\(j\) 时第 \(i\) 种物品是否被选. 为保证从小到大和字典序,先将瓶子按大小排序 ...
- vuemock数据
http://www.jianshu.com/p/ccd53488a61b dev.server.js 61 行 app.use('/mock',express.static('./mock'))
- error: ‘to_string’ was not declared in this scope
错误: error: ‘to_string’ was not declared in this scope 原因: to_string是C++11引入的新功能,旧版本编译器可能不支持它,所以要给编译器 ...
- [暑假集训--数论]poj3518 Prime Gap
The sequence of n − 1 consecutive composite numbers (positive integers that are not prime and not eq ...
- nginx和php安装文件
#!/usr/bin/env bash echo "=============START=====================" ## php echo '[php]yum i ...
- java网络编程学习笔记(三):ServerSocket详解
1.ServerSocket的构造方法 ServerSocket(); ServerSocket(int port); ServerSocket(int port,int backlog); Serv ...
- 剖析CPU温度监控技术【转】
转自:http://blog.csdn.net/hunanchenxingyu/article/details/46476545 迄今为止还没有一种cpu散热系统能保证永不失效.失去了散热系统保护伞的 ...