当前位置:网站首页>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 .
边栏推荐
- Debug:==42==ERROR: AddressSanitizer: heap-buffer-overflow on address
- Batch distribution of SSH keys and batch execution of ansible
- Dos:disk operating system, including core startup program and command program
- What is an excellent architect in my heart?
- [200 opencv routines] 218 Multi line italic text watermark
- Velodyne configuration command
- Knapsack problem and 0-1 knapsack problem
- Exercise 7-3 store the numbers in the array in reverse order (20 points)
- When I forget how to write SQL, I
- Network disk installation
猜你喜欢
Architecture introduction
C language - stack
Devop basic command
From programmers to large-scale distributed architects, where are you (I)
Some summaries of the third anniversary of joining Ping An in China
[200 opencv routines] 218 Multi line italic text watermark
Basic data types of MySQL
If you don't know these four caching modes, dare you say you understand caching?
Time complexity and space complexity
How do microservices aggregate API documents? This wave of show~
随机推荐
Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 1
How to teach yourself to learn programming
Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
转载:等比数列的求和公式,及其推导过程
2020-03-28
入职中国平安三周年的一些总结
Rhcsa day 10 operation
7-17 crawling worms (15 points)
AUTOSAR from getting started to mastering 100 lectures (106) - SOA in domain controllers
Development guidance document of CMDB
Crawl Zhejiang industry and trade news page
Vs201 solution to failure to open source file HPP (or link library file)
Exercise 7-3 store the numbers in the array in reverse order (20 points)
Exercise 7-2 finding the maximum value and its subscript (20 points)
Delayed message center design
Latex arranges single column table pictures in double column format articles
Work order management system OTRs
Exercise 7-8 converting strings to decimal integers (15 points)
Lavel document reading notes -how to use @auth and @guest directives in lavel
Knapsack problem and 0-1 knapsack problem