当前位置:网站首页>Large number processing -- use case
Large number processing -- use case
2022-07-25 02:09:00 【Zinksl】
List of articles
1 The processing of large integers uses BigInteger
Code example :
public class BigNumber {
public static void main(String[] args) {
BigInteger bigInteger = new BigInteger("123456789123456");
BigInteger bigInteger2 = new BigInteger("123321");
BigInteger temp;
// Add
temp = bigInteger.add(bigInteger2);
System.out.println(bigInteger+" And "+bigInteger2+" And for :"+temp);
// Subtraction
temp = bigInteger.subtract(bigInteger2);
System.out.println(bigInteger+" And "+bigInteger2+" The difference is :"+temp);
// Multiplication
temp = bigInteger.multiply(bigInteger2);
System.out.println(bigInteger+" And "+bigInteger2+" The product of is :"+temp);
// division
temp = bigInteger.divide(bigInteger2);
System.out.println(bigInteger+" And "+bigInteger2+" My business is :"+temp);
}
}
2 Size number processing use
Code example :
public class BigDecimalDemo {
public static void main(String[] args) {
BigDecimal bd1 = new BigDecimal("15113151315131.15153151652");
BigDecimal bd2 = new BigDecimal("5");
BigDecimal temp;
// Add
temp = bd1.add(bd2);
System.out.println(" And for :"+temp);
// Subtraction
temp = bd1.subtract(bd2);
System.out.println(" The difference is :"+temp);
// Multiplication
temp = bd1.multiply(bd2);
System.out.println(" Product as :"+temp);
// division
temp = bd1.divide(bd2);
System.out.println(" Shang Wei :"+temp);
}
}
边栏推荐
- Today in history: the kotlin language was published for the first time; The father of the IMAP agreement was born; CT imaging achieves a new breakthrough
- Redis learning notes (2) - power node of station B
- Mongodb security cluster construction
- Babbitt | metauniverse daily must read: Dubai launched the national metauniverse strategy, which plans to increase the number of related companies of metauniverse by five times in the next five years
- Open source demo | release of open source example of arcall applet
- R language uses logistic regression, ANOVA, outlier analysis and visual classification iris iris data set
- Win10 configuring CUDA and cudnn
- Open source demo | release of open source example of arcall applet
- [linear DP] Digital triangle
- Let's customize the loader
猜你喜欢

How to use ES6 async and await (basic)

2022/7/18-7/19
Windows Server 2022 received a non security update in July: fix the sticking problem caused by defender

1260. Two dimensional grid migration: simple construction simulation problem

Yunyuanyuan (VIII) | Devops in depth Devops

An article explains unsupervised learning in images in detail

Talk about what's going on with C # backstage GC?

Research 280+ documents! The team of Tsinghua Huang Gao, the winner of CVPR best paper, proposed the first dynamic network overview to comprehensively review the development of dynamic networks!

Hongmeng harmonyos 3 official announcement: officially released on July 27; Apple slowed down the recruitment and expenditure of some teams in 2023; Russia fined Google 2.6 billion yuan | geek headlin

Google launched another "man grabbing war" for core making, and Intel's 17 year veteran joined!
随机推荐
What do growth enterprises need most to build a data-driven organization?
Mobile Robotics (3) Kalman filter
Win10 configuring CUDA and cudnn
Scalar, vector, matrix calculus
An article explains unsupervised learning in images in detail
AWD thinking
[summer daily question] Luogu P7550 [coci2020-2021 6] bold
Open source demo | release of open source example of arcall applet
It's still a synchronization problem
[hero planet July training leetcode problem solving daily] 20th BST
[summer daily question] Luogu p1605 maze
Fraud detection using CSP
"Nowadays, more than 99.9% of the code is garbage!"
Create the first hbuilder project
In the post deep learning era, where is the recommendation system going?
Computing network, AI first, shengteng AI helps operators' Digital Transformation -- work together to win-win Computing Era
Consul cluster deployment
Detailed explanation of the principles and differences between static pages and dynamic pages
Peripherals: interrupt system of keys and CPU
Agreement on sharing agricultural scientific data in China