当前位置:网站首页>Huge number multiplication (C language)
Huge number multiplication (C language)
2022-07-04 10:27:00 【Lol only plays Timo】
In the last blog, we realized the addition and subtraction of huge numbers , Now let me fill in the hole left at the end of my last blog —— Multiplication of huge numbers .
It is easier to realize multiplication than addition and subtraction , We can analogy multiplication under decimal system to realize manual process .
Since the decimal multiplication is so, so should the multiplication under the ten thousand system , But how to solve the storage problem of each calculation result , This problem bothered me for a long time when I was programming .
It's very simple , Is that we put every round ( Or every time ) The calculation result of is directly stored in the array of our huge number of results in 10000 decimal .
by the way , In the final result, the number of digits of a huge number should be the sum of two multiplied huge digits ( In decimal ).
Let's take a look at the core code :
void multiInfor(HUGE_NUM *NUM1, HUGE_NUM *NUM2, HUGE_NUM *NUM3) {
int i;
int j;
int count1 = (NUM1->count+3) / 4;
int count2 = (NUM2->count+3) / 4;
int temp;
int cur;
int next;
NUM3->sign = NUM1->sign ^ NUM2->sign;
for (i = 0; i < count1; i++) {
for (j = 0; j < count2; j++) {
temp = NUM1->value[i] * NUM2->value[j] + NUM3->value[i+j];
cur = temp % 10000;
next = temp / 10000;
NUM3->value[i+j] = cur;
NUM3->value[i+j+1] = next;
}
}
}
Other codes are the same as those of the addition and subtraction of huge numbers , You can get what you need in my last blog .
thus , A huge number of projects are over , As for decimal and division, I still have some deficiencies in time and ability, and I can't fully realize it for the time being .
All the guidance of this project comes from teacher Zhu Hong of wechat .
边栏推荐
- Linked list operation can never change without its roots
- uniapp---初步使用websocket(长链接实现)
- Collection of practical string functions
- leetcode1-3
- 【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
- 转载:等比数列的求和公式,及其推导过程
- Some summaries of the third anniversary of joining Ping An in China
- Delayed message center design
- 【Day1】 deep-learning-basics
- Service developers publish services based on EDAs
猜你喜欢

Occasional pit compiled by idea

Machine learning -- neural network (IV): BP neural network

Hands on deep learning (46) -- attention mechanism

OSPF comprehensive experiment

Doris / Clickhouse / Hudi, a phased summary in June

Debug:==42==ERROR: AddressSanitizer: heap-buffer-overflow on address

Collection of practical string functions

PHP code audit 3 - system reload vulnerability

六月份阶段性大总结之Doris/Clickhouse/Hudi一网打尽

【Day2】 convolutional-neural-networks
随机推荐
Kotlin: collection use
The time difference between the past time and the present time of uniapp processing, such as just, a few minutes ago, a few hours ago, a few months ago
Doris / Clickhouse / Hudi, a phased summary in June
Latex arranges single column table pictures in double column format articles
Histogram equalization
Collection of practical string functions
Servlet基本原理与常见API方法的应用
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
Exercise 8-10 output student grades (20 points)
System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
leetcode1229. Schedule the meeting
MongoDB数据日期显示相差8小时 原因和解决方案
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
Reprint: summation formula of proportional series and its derivation process
View CSDN personal resource download details
转载:等比数列的求和公式,及其推导过程
Whether a person is reliable or not, closed loop is very important
Reasons and solutions for the 8-hour difference in mongodb data date display
Container cloud notes
C language - stack