当前位置:网站首页>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 .
边栏推荐
- 2. Data type
- Ruby时间格式转换strftime毫秒匹配格式
- Static comprehensive experiment ---hcip1
- Differences among opencv versions
- 7-17 crawling worms (15 points)
- Application of safety monitoring in zhizhilu Denggan reservoir area
- 【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
- If you don't know these four caching modes, dare you say you understand caching?
- Remove linked list elements
- Advanced technology management - how to design and follow up the performance of students at different levels
猜你喜欢
Sword finger offer 05 (implemented in C language)
Two way process republication + routing policy
Delayed message center design
Tables in the thesis of latex learning
Vs201 solution to failure to open source file HPP (or link library file)
【Day1】 deep-learning-basics
对于程序员来说,伤害力度最大的话。。。
Knapsack problem and 0-1 knapsack problem
Servlet基本原理与常见API方法的应用
Devop basic command
随机推荐
【OpenCV 例程200篇】218. 多行倾斜文字水印
Dos:disk operating system, including core startup program and command program
C language - stack
MPLS: multi protocol label switching
Es entry series - 6 document relevance and sorting
Check 15 developer tools of Alibaba
BGP advanced experiment
Rhcsa day 9
MySQL develops small mall management system
Application of safety monitoring in zhizhilu Denggan reservoir area
What is an excellent architect in my heart?
Online troubleshooting
C language structure to realize simple address book
Latex learning insertion number - list of filled dots, bars, numbers
Deep learning 500 questions
If you don't know these four caching modes, dare you say you understand caching?
Es advanced series - 1 JVM memory allocation
A little feeling
MongoDB数据日期显示相差8小时 原因和解决方案
Container cloud notes