当前位置:网站首页>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);
}
}
边栏推荐
- How to upload files to the server
- Open sharing of scientific data in the context of open science: the practice of the national Qinghai Tibet Plateau scientific data center
- Download files and web pages with WGet
- Windows Server 2022 received a non security update in July: fix the sticking problem caused by defender
- "Nowadays, more than 99.9% of the code is garbage!"
- Industrial control safety PLC firmware reverse III
- [linear DP] Digital triangle
- Industrial control safety PLC firmware reverse II
- KVM virtualization jobs
- 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
猜你喜欢

BMW I3 based on clar architecture is not a simple "oil to electricity" product

iptables :chains, target

Detailed explanation of manually writing servlet in idea

What are the important trends revealed by the release of "operator data viability index"?

Simulate the implementation of StrCmp function

Industrial control safety PLC firmware reverse II

Scalar, vector, matrix calculus

Server performance monitoring

High performance memory recovery technology for decrypting ark -- HPP GC

1260. Two dimensional grid migration: simple construction simulation problem
随机推荐
Freedom and self action Hegel
POM reports an error
VRRP virtual redundancy protocol configuration
[summer daily question] Luogu p1605 maze
6-10 vulnerability exploitation SMTP experimental environment construction
Hbuilderx developed by uni app connects to night God simulator
Completefuture parallel asynchronous return processing
Google launched another "man grabbing war" for core making, and Intel's 17 year veteran joined!
Thinkphp5.0.24 deserialization chain analysis
Performance analysis method - Notes on top of performance
ByteDance confirmation will be self-developed chip: for internal use only; Musk: I have uploaded my brain to the cloud; Go language product head leaves | geek headline
After upgrading v2.1.0, the synchronization failed
High performance memory recovery technology for decrypting ark -- HPP GC
An article explains unsupervised learning in images in detail
Harbor installation
PostgreSQL views tables, table indexes, views, table structures, and parameter settings
R language uses logistic regression, ANOVA, outlier analysis and visual classification iris iris data set
Scalar, vector, matrix calculus
Web Security Foundation - file upload
Why can't reading more books improve your writing?