当前位置:网站首页>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 .
边栏推荐
- How can Huawei online match improve the success rate of player matching
- Software sharing: the best PDF document conversion tool and PDF Suite Enterprise version sharing | with sharing
- Differences among opencv versions
- 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
- Hlk-w801wifi connection
- PHP code audit 3 - system reload vulnerability
- Exercise 9-3 plane vector addition (15 points)
- Time complexity and space complexity
- Vanishing numbers
- Jianzhi offer 04 (implemented in C language)
猜你喜欢

Time complexity and space complexity

Servlet基本原理与常见API方法的应用

Vs201 solution to failure to open source file HPP (or link library file)

【Day1】 deep-learning-basics

system design

Evolution from monomer architecture to microservice architecture

对于程序员来说,伤害力度最大的话。。。

leetcode1-3

Hands on deep learning (46) -- attention mechanism

Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 1
随机推荐
Rhcsa12
Rhsca day 11 operation
Exercise 7-8 converting strings to decimal integers (15 points)
[FAQ] summary of common causes and solutions of Huawei account service error 907135701
Talk about scalability
Sword finger offer 31 Stack push in and pop-up sequence
Hlk-w801wifi connection
How do microservices aggregate API documents? This wave of show~
Reasons and solutions for the 8-hour difference in mongodb data date display
Exercise 8-7 string sorting (20 points)
Does any teacher know how to inherit richsourcefunction custom reading Mysql to do increment?
Pod management
Collection of practical string functions
Introduction to tree and binary tree
Press the button wizard to learn how to fight monsters - identify the map, run the map, enter the gang and identify NPC
Dos:disk operating system, including core startup program and command program
When I forget how to write SQL, I
uniapp 处理过去时间对比现在时间的时间差 如刚刚、几分钟前,几小时前,几个月前
【Day2】 convolutional-neural-networks
Rhcsa day 9