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 。 
时间: 2024-08-26 17:08:20

JAVA中大数常用的函数的相关文章

java中最常用jar包的用途说明

java中最常用jar包的用途说明,适合初学者 jar包 用途 axis.jar SOAP引擎包 commons-discovery-0.2.jar 用来发现.查找和实现可插入式接口,提供一些一般类实例化.单件的生命周期管理的常用方法. jaxrpc.jar Axis运行所需要的组件包 saaj.jar 创建到端点的点到点连接的方法.创建并处理SOAP消息和附件的方法,以及接收和处理SOAP错误的方法.   wsdl4j-1.5.1.jar Axis运行所需要的组件包 activation.ja

Java中执行存储过程和函数(web基础学习笔记十四)

一.概述 如果想要执行存储过程,我们应该使用 CallableStatement 接口. CallableStatement 接口继承自PreparedStatement 接口.所以CallableStatement 接口包含有Statement 接口和PreparedStatement 接口定义的全部方法,但是并不是所有的方法我们都要使用,主要使用的方法有这样几个: CallableStatement 常用方法: 返回类型 方法签名 说明 boolean execute() 执行 SQL 语句

java 中的常用类

Java 中的包装类 相信各位小伙伴们对基本数据类型都非常熟悉,例如 int.float.double.boolean.char 等. 基本数据类型是不具备对象的特性的,比如基本类型不能调用方法.功能简单..., 为了让基本数据类型也具备对象的特性, Java 为每个基本数据类型都提供了一个包装类,这样我们就可以像操作对象那样来操作基本数据类型. 包装类主要提供了两大类方法: 1. 将本类型和其他基本类型进行转换的方法 2. 将字符串和本类型及包装类互相转换的方法 Integer 常用的方法 p

java中的字符串分割函数

java中的split函数和js中的split函数不一样. Java中的我们可以利用split把字符串按照指定的分割符进行分割,然后返回字符串数组,下面是string.split的用法实例及注意事项: java.lang.string.split split 方法 将一个字符串分割为子字符串,然后将结果作为字符串数组返回. stringObj.split([separator,[limit]]) stringObj 必选项.要被分解的 String 对象或文字,该对象不会被split方法修改.

python中print()函数的“,”与java中System.out.print()函数中的“+”

python中的print()函数和java中的System.out.print()函数都有着打印字符串的功能. python中: print("hello,world!") 输出结果为:hello,world! java中: System.out.print("hello,world!"); 输出结果为:hello,world! 我们可以看到,这两个函数的用法是一样的 print()函数还有这种用法: print("1+1=",1+1) 输出结

java中的+与append函数

Java中的+与append都可以对字符串类型的对象进行追加,那么这两个又有什么区别呢? 博文http://blog.csdn.net/shirleyacount/article/details/39958371 中有具体的描述,相信看过之后,就会明白了. 以下是append方法的API 可以看到append方法返回的值均为StringBuffer类型的 StringBuffer的简述中有如下描述: 而StringBuilder的简述中有如下描述: 所以可见一般情况下执行速度有:StringBu

Java学习(十一):Java中的常用时间操作

java中的时间操作不外乎这四种情况:获取当前时间,获取某个时间的某种格式,设置时间和时间的运算. 1.获取当前时间 有两种方式可以获得,第一种,使用java.util.Date类. Date date = new Date(); date.getTime(); 还有一种方式,使用System.currentTimeMillis(); 这两种方式获得的结果是一样的,都是得到一个当前的时间的long型的时间的毫秒值,这个值实际上是当前时间值与1970年一月一号零时零分零秒相差的毫秒数. 2.获取某

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 ()

JAVA中最常用的快捷键总结

1. ctrl+shift+r:打开资源 这可能是所有快捷键组合中最省时间的了.这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的前几个字母,比如applic*.xml.美中不足的是这组快捷键并非在所有视图下都能用. 2. ctrl+o:快速outline 如果想要查看当前类的方法或某个特定方法,但又不想把代码拉上拉下,也不想使用查找功能的话,就用ctrl+o吧.它可以列出当前类中的所有方法及属性,你只需输入你想要查询的方法名,点击enter就能够直接跳转至你想