当前位置:网站首页>大数处理--使用案例
大数处理--使用案例
2022-07-20 09:40:00 【Zinksl】
1 大整数的处理使用BigInteger
代码示例:
public class BigNumber {
public static void main(String[] args) {
BigInteger bigInteger = new BigInteger("123456789123456");
BigInteger bigInteger2 = new BigInteger("123321");
BigInteger temp;
// 加法
temp = bigInteger.add(bigInteger2);
System.out.println(bigInteger+"与"+bigInteger2+"的和为:"+temp);
// 减法
temp = bigInteger.subtract(bigInteger2);
System.out.println(bigInteger+"与"+bigInteger2+"的差为:"+temp);
// 乘法
temp = bigInteger.multiply(bigInteger2);
System.out.println(bigInteger+"与"+bigInteger2+"的积为:"+temp);
// 除法
temp = bigInteger.divide(bigInteger2);
System.out.println(bigInteger+"与"+bigInteger2+"的商为:"+temp);
}
}
2 大小数处理使用
代码示例:
public class BigDecimalDemo {
public static void main(String[] args) {
BigDecimal bd1 = new BigDecimal("15113151315131.15153151652");
BigDecimal bd2 = new BigDecimal("5");
BigDecimal temp;
// 加法
temp = bd1.add(bd2);
System.out.println("和为:"+temp);
// 减法
temp = bd1.subtract(bd2);
System.out.println("差为:"+temp);
// 乘法
temp = bd1.multiply(bd2);
System.out.println("积为:"+temp);
// 除法
temp = bd1.divide(bd2);
System.out.println("商为:"+temp);
}
}
边栏推荐
- NepCTF
- Query the space occupied by a table and the amount of data in the table
- How to write technical documents - this is all my experience
- Extract excel header
- [postgraduate entrance examination vocabulary training camp] day 8 - complete, traditional, extra, aford, professional, required
- 低代码开发平台搭建会展服务管理系统案例分析
- pycharm 写 sqlite 语句没有代码提示
- SQL语句问题,不知道是否正确,求指导
- Change your posture to do operation and maintenance! GOPs 2022 Shenzhen station highlights first!
- NepCTF
猜你喜欢
提取excel表头
Change your posture to do operation and maintenance! GOPs 2022 Shenzhen station highlights first!
Cookie和Session
mysql 5.7windows环境安装
web安全入门-telent测试与防御
Linear table with chained storage structure
分类中ICO对象
[email protected] Moveexecutionstosingleactivityid parallel gateway or inclusive gateway fallback"/>
Learning records [email protected] Moveexecutionstosingleactivityid parallel gateway or inclusive gateway fallback
安科瑞马达监控方案低压电动机回路及馈线配电回路电力能源监测
What is stack?
随机推荐
Application of linked list
2022年个人理财产品都有哪些种类?
Redis-数据结构&&通用命令
数商云:如何实现供应商SRM管理系统的应用价值?
Strcat () - connection string
[postgraduate entrance examination vocabulary training camp] day 8 - complete, traditional, extra, aford, professional, required
File文件改名字
Some summary of QT | QWidget
自定义持久层框架MyORMFramework(二)—框架设计
大佬们,请问 PostgreSQL CDC ,PostgreSQL 必须配置逻辑复制吗? 目前部署的
PHP collection function
牛客-TOP101-BM33
KUDU1.11 环境安装
CentOS install MySQL
Unity学习笔记 球形全景图平面像素坐标与三维坐标系上的坐标之间的转换
Query the space occupied by a table and the amount of data in the table
Kettle [practice 03] details of difficulties in classification, analysis and warehousing of KML type files in Shuijing micrograph (complete process example cloud resource sharing: including sql+kjb+kt
Flutter 苹果原生拼音键盘在TextField上输入异常 | 拼音输入过程回调问题
文本读取结束判定
Try to understand the essence of low code platform design from another angle