类BigInteger
2024-08-31 11:19:17
BigInteger类
可以让超过Integer范围内的数据进行运算
构造方法
public BigIntege(String val);
package com.jacky; import java.math.BigInteger; public class IntegerDemo { public static void main(String[] args) {
// TODO Auto-generated method stub Integer i = new Integer(100);
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE); BigInteger bi = new BigInteger("2147483648");
System.out.println("bi:" + bi);
}
}
/*
* public BigInteger add(BigInteger val);//加
* public BigInteger subtract(BigInteger val);//减
* public BigInteger multiply(BigInteger val);//乘
* public BigInteger divide(BigInteger val);//除
* public BigInteger[] divideAndRemainder(BigInteger val);//返回商和余数的数组
* */
import java.math.BigInteger; /*
* public BigInteger add(BigInteger val);//加
* public BigInteger subtract(BigInteger val);//减
* public BigInteger multiply(BigInteger val);//乘
* public BigInteger divide(BigInteger val);//除
* public BigInteger[] divideAndRemainder(BigInteger val);//返回商和余数的数组
* */ public class IntegerDemo { public static void main(String[] args) {
// TODO Auto-generated method stub BigInteger bi1 = new BigInteger("100");
BigInteger bi2 = new BigInteger("50"); System.out.println("add:" + bi1.add(bi2));
System.out.println("subtract:" + bi1.subtract(bi2));
System.out.println("multiply:" + bi1.multiply(bi2));
System.out.println("divide:" + bi1.divide(bi2)); BigInteger bis[] = bi1.divideAndRemainder(bi2);
System.out.println("商:" + bis[0]);
System.out.println("余数、:" + bis[1]);
}
}
最新文章
- html input readonly 和 disable的区别
- Swift与Objective-C交互
- (数字IC)低功耗设计入门(一)
- 【京东详情页】——原生js爬坑之放大镜
- echarts 图表后面背景色
- DedeCMS找后台目录漏洞
- sql 多行转多列,多行转一列合并数据,列转行
- Daily Scrumming* 2015.12.12(Day 4)
- O'Reilly总裁提姆-奥莱理:什么是Web 2.0
- Linux 性能工具安装部署
- Python 自动补全(vim)
- Jira 6.0.5的详细安装及汉化授权
- C++与C#的多态
- Android规划周期任务
- Python:文件的读取、创建、追加、删除、清空
- 【离散数学】SDUT OJ 指定长度路径数
- 添加win10激活工具
- [转]NME Android目标中文输入问题完美解决!
- 1.centos7 安装zookeeper
- android hook 框架 libinject2 如何实现so注入
热门文章
- 我国三大常用坐标系:北京54、西安80和WGS-84
- 设计模式开闭原则--java
- SPSS Statistics 多个版本的下载安装激活步骤
- nsswitch.conf - 系统数据库及名字服务开关配置文件
- Django中间件拦截未登录url
- Codeforces 939 时区模拟 三分
- 1130. Infix Expression (25)
- sharepoint 2010 创建自定义的ASP.NET Web Service (上)
- linux运维、架构之路-Git+Jenkins实现自动化部署
- 前端node面试题之---对比JS和NodeJS的区别