BigInteger 用法详解
来源:互联网 发布:淘宝限购一件怎么设置 编辑:程序博客网 时间:2024/06/16 22:43
import java.math.BigInteger;import java.util.Scanner;
in = Scanner (System.in);
输入
while(in.hasNext()) //等价于!=EOF,循环读入数据int n=in.nextInt(); //读入一个int型的数
String s=new String()
s=in.nextLine(); //读入字符串
BigInteger m=in.nextBigInteger(); //读入一个大整数
输出:
System.out.print(n); //打印n
System.out.println(); //换行System.out.printf("%d\n",n); //也可以类似c++里的输出方式
BigInteger.valueOf(int n) //大数类型
BigInteger a=new BigInteger(“100”)
大数 a 调用以下函数
add(BigInteger n); //加法
subtract(BigInteger n) //减法
multiply(BigInteger n) //乘法
divide(BigInteger n) //除法
remainder(BigInteger n) //取余(模)
divideAndRemainder(BigInteger n):a[0]=this / n; a[1]=this % n //除数加余数
compareTo(BigInteger n) //大于返回1,等于0,小于-1
pow(int b)=a^b //幂函数
modPow(BigInteger n,BigInteger m) a^n%m //幂函数模
min(BigInteger n) ,max(BigInteger n) //取两个数的较小、大者
intValue(),longValue(),floatValue(),doublue() //返回该类型的数的值。
gcd(BigInteger n) //公约数
abs(BigInteger n) //绝对值
isProbablePrime(int n) //判断是否是素数,是返回true,否则返回false
negate () //取负数,无形参
and(BigInteger n) //&&, &;
or(BigInteger n) // ||,|;
xor(BigInteger n) //异或
toString() //返回转换成的字符串,无形参
toString(int n) //返回转换成n进制的字符串,无形参*
not() // ! 正数变负数,负数变正数,暂时不知实际意义
- BigInteger 用法详解
- BigInteger用法
- BigInteger详解
- BigInteger详解
- BigInteger详解
- BigInteger详解
- BigInteger详解
- BigInteger实际用法
- BigInteger实际用法
- BigInteger的相关用法
- BigDecimal和BigInteger详解
- Java中BigInteger详解
- java中BigInteger的用法
- java BigInteger类的用法
- BigInteger类的一些用法
- BigInteger
- BigInteger
- BigInteger
- MSF学习笔记(7)
- 关键路径 C语言实现
- js时间格式化
- python函数参数
- hibernate持久化框架(Spring+springMVC+hibernate)
- BigInteger 用法详解
- ScheduledExecutorService执行周期性或定时任务
- 吴恩达深度学习笔记(四)week2深度卷积神经网络实例
- Android Study Material Design 十三 之CoordinatorLayout交互动画
- Windows7下Git 的使用笔记
- 第一个three.js程序
- 高斯混合模型:不掉包实现多维数据聚类分析
- win10下安装配置Java web开发环境(win10+jdk1.8+tomcat8.5+mysql5.7)
- Fragment集成