当前位置:网站首页>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 .
边栏推荐
- Basic principle of servlet and application of common API methods
- Tables in the thesis of latex learning
- Es entry series - 6 document relevance and sorting
- 使用 C# 提取 PDF 文件中的所有文字(支持 .NET Core)
- Button wizard business running learning - commodity quantity, price reminder, judgment Backpack
- Exercise 9-4 finding books (20 points)
- 【Day1】 deep-learning-basics
- OSPF summary
- 转载:等比数列的求和公式,及其推导过程
- MPLS: multi protocol label switching
猜你喜欢

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

leetcode1-3

Doris / Clickhouse / Hudi, a phased summary in June

Seven examples to understand the storage rules of shaped data on each bit

Sword finger offer 05 (implemented in C language)

From programmers to large-scale distributed architects, where are you (2)

2. Data type

Software sharing: the best PDF document conversion tool and PDF Suite Enterprise version sharing | with sharing

Rhcsa - day 13

Hands on deep learning (46) -- attention mechanism
随机推荐
Rhcsa operation
【Day2】 convolutional-neural-networks
leetcode1-3
【Day1】 deep-learning-basics
用数据告诉你高考最难的省份是哪里!
Dynamic memory management
【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
Exercise 8-10 output student grades (20 points)
Basic data types of MySQL
Reprint: summation formula of proportional series and its derivation process
Development guidance document of CMDB
Exercise 9-3 plane vector addition (15 points)
BGP ---- border gateway routing protocol ----- basic experiment
Online troubleshooting
Container cloud notes
Batch distribution of SSH keys and batch execution of ansible
Software sharing: the best PDF document conversion tool and PDF Suite Enterprise version sharing | with sharing
Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 2
【Day1】 deep-learning-basics
Histogram equalization