当前位置:网站首页>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 .
边栏推荐
- Introduction to tree and binary tree
- Machine learning -- neural network (IV): BP neural network
- Four characteristics and isolation levels of database transactions
- Linked list operation can never change without its roots
- Whether a person is reliable or not, closed loop is very important
- 使用 C# 提取 PDF 文件中的所有文字(支持 .NET Core)
- Delayed message center design
- Remove linked list elements
- Today's sleep quality record 78 points
- 2020-03-28
猜你喜欢
![[FAQ] summary of common causes and solutions of Huawei account service error 907135701](/img/73/c4ee842475f05e2e67297fcac68779.png)
[FAQ] summary of common causes and solutions of Huawei account service error 907135701

Knapsack problem and 0-1 knapsack problem

How can Huawei online match improve the success rate of player matching

VLAN part of switching technology

Latex error: missing delimiter (. Inserted) {\xi \left( {p,{p_q}} \right)} \right|}}

PHP代码审计3—系统重装漏洞

Linked list operation can never change without its roots

Rhcsa day 9

Work order management system OTRs

Static comprehensive experiment ---hcip1
随机推荐
Realsense of d435i, d435, d415, t265_ Matching and installation of viewer environment
MPLS: multi protocol label switching
For programmers, if it hurts the most...
基于线性函数近似的安全强化学习 Safe RL with Linear Function Approximation 翻译 1
Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 2
用数据告诉你高考最难的省份是哪里!
Dynamic memory management
Seven examples to understand the storage rules of shaped data on each bit
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
Basic principle of servlet and application of common API methods
Some summaries of the third anniversary of joining Ping An in China
Use C to extract all text in PDF files (support.Net core)
When I forget how to write SQL, I
Press the button wizard to learn how to fight monsters - identify the map, run the map, enter the gang and identify NPC
leetcode1-3
Delayed message center design
Two way process republication + routing policy
Network disk installation
Dynamic memory management
Exercise 8-10 output student grades (20 points)