Java BigInteger类| 带实例的splitAndRemainder()方法
BigInteger类divideAndRemainder()方法 (BigInteger Class divideAndRemainder() method)
divideAndRemainder() method is available in java.math package.
splitAndRemainder()方法在java.math包中可用。
divideAndRemainder() method returns BigInteger array of 2 elements that contain quotient that is calculated by using (this BigInteger)/(BigInteger val) followed by the remainder that is calculated by using (this BigInteger) % (BigInteger val).
splitAndRemainder()方法将返回由2个元素组成的BigInteger数组,其中包含使用(this BigInteger)/(BigInteger val)计算得出的商数,然后返回使用(this BigInteger)%(BigInteger val)计算得出的余数。
divideAndRemainder() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
splitAndRemainder()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
divideAndRemainder() method may throw an exception at the time of calculating the remainder.
在计算余数时, divideAndRemainder()方法可能会引发异常。
ArithmeticException: This exception may throw when the given parameter holds value 0.
ArithmeticException:当给定参数的值为0时,可能引发此异常。
Syntax:
句法:
public BigInteger[] divideAndRemainder(BigInteger val);
Parameter(s):
参数:
BigInteger val – represents the value by which this BigInteger is to be divided and generate remainder.
BigInteger val –表示该BigInteger被除以并生成余数的值。
Return value:
返回值:
The return type of this method is BigInteger[], it returns an array of BigInteger of two element of "BigInteger" type and the quotient is calculated by using (this BigInteger)/ (BigInteger val) and the remainder is calculated by using (this BigInteger) % (BigInteger val).
此方法的返回类型为BigInteger [] ,它返回两个由BigInteger类型组成的元素的BigInteger数组,商是使用(this BigInteger)/(BigInteger val)计算的,余数是使用(this BigInteger)%(BigInteger val)。
Example:
例:
// Java program to demonstrate the example
// of divideAndRemainder(BigInteger val) method of BigInteger
import java.math.*;
public class DivideAndRemainderOfBI {public static void main(String args[]) {// Initialize two variables divi, divisr
String divi = "120";
String divisr = "4";
// Initialize two BigInteger objects
BigInteger b_int1 = new BigInteger(divi);
BigInteger b_int2 = new BigInteger(divisr);
// Display b_int1 and b_int2
System.out.println("b_int1: " + b_int1);
System.out.println("b_int2: " + b_int2);
System.out.println("divideAndRemainder(BigInteger): ");
// divides this BigInteger (b_int1) by the
// given BigInteger (b_int2) and return the BigInteger[]
// of two values (Quotient, Remainder)
BigInteger[] div_rem = b_int1.divideAndRemainder(b_int2);
System.out.println("Quotient div_rem[0]: " + div_rem[0]);
System.out.println("Remainder div_rem[1]: " + div_rem[1]);
}
}
Output
输出量
b_int1: 120
b_int2: 4
divideAndRemainder(BigInteger):
Quotient div_rem[0]: 30
Remainder div_rem[1]: 0
翻译自: https://www.includehelp.com/java/biginteger-divideandremainder-method-with-example.aspx
Java BigInteger类| 带实例的splitAndRemainder()方法相关推荐
- Java BigInteger类| 带示例的shiftLeft()方法
BigInteger类shiftLeft()方法 (BigInteger Class shiftLeft() method) shiftLeft() method is available in ja ...
- Java——BigInteger类和BigDecimal类
Java--BigInteger类和BigDecimal类 摘要:本文主要学习了用于大数字运算的BigInteger类和BigDecimal类. 部分内容来自以下博客: https://www.cnb ...
- Java BigInteger类| modInverse()方法与示例
BigInteger类modInverse()方法 (BigInteger Class modInverse() method) modInverse() method is available in ...
- Java BigInteger类| and()方法与示例
BigInteger类和()方法 (BigInteger Class and() method) and() method is available in java.math package. and ...
- Java BigInteger类| xor()方法与示例
BigInteger类的xor()方法 (BigInteger Class xor() method) xor() method is available in java.math package. ...
- Java BigInteger类| 带有示例的减去()方法
BigInteger类减去()方法 (BigInteger Class subtract() method) subtract() method is available in java.math p ...
- Java BigInteger类| toByteArray()方法与示例
BigInteger类testBit()方法 (BigInteger Class testBit() method) testBit() method is available in java.mat ...
- Java BigInteger类| nextProbablePrime()方法与示例
BigInteger类nextProbablePrime()方法 (BigInteger Class nextProbablePrime() method) nextProbablePrime() m ...
- Java BigInteger类| bitCount()方法与示例
BigInteger类的bitCount()方法 (BigInteger Class bitCount() method) bitCount() method is available in java ...
最新文章
- SPQuery 查询知多少
- es6 --- Proxy实例的get方法
- 前端学习(1437):vue一些链接
- 恭喜!已获8个院士的他,又新当选德国院士!
- 不高兴的津津(洛谷-P1085)
- discuz常用变量
- html图片上传阅览并且点击放大
- 5款Mac必备的Safari扩展
- MATLAB矩阵合并
- Android开发入门案例
- Autodesk AutoCAD 2022 产品系列已发布(附下载)
- Principal branch
- S32K144之SDK版:CAN模块应用
- Ubuntu和windows之间复制粘贴,遇到无法安装Vmware-tools
- MySQL设置白名单,允许单个IP或某段节点登录
- 天龙八部架设IP配置文件
- matlab中的sjy定义,sjy(sjy是什么缩写)
- python监控文件或目录变化
- 安卓手机在fastboot模式下刷机
- 《匆匆那年》的你,还记得吗?数学中的那些有(hui)趣(se)的定理(1)——鸟头定理
热门文章
- 半个小时用计算机怎么算,CPA机考计算器操作指南,掌握这些快捷键,考试“延长”半小时!...
- dbgrideh 为什么只一行_Mysql性能优化:为什么count(*)这么慢?
- python软件_Python自制照片美颜软件~
- python123平台作业答案第十一周_马哥2016全新Linux+Python高端运维班第十次作业
- python自定义安装哪些不需要_【1】python模块:自定义模块的3种导入方式
- 地理信息系统软件测试培训,地理信息系统软件测试方法技术方案
- php函数内的循环,PHP 循环列出目录内容的函数代码
- mqtt php 16进制数据,phpMQTT 内存耗死问题
- util.java_TelnetUtil.java
- Redis之Redis内存模型