当前位置:网站首页>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 .
边栏推荐
- 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
- Rhcsa day 9
- Batch distribution of SSH keys and batch execution of ansible
- Read a piece of text into the vector object, and each word is stored as an element in the vector. Convert each word in the vector object to uppercase letters. Output the converted elements in the vect
- 六月份阶段性大总结之Doris/Clickhouse/Hudi一网打尽
- Number of relationship models
- 【Day2】 convolutional-neural-networks
- leetcode729. My schedule 1
- leetcode1-3
- Does any teacher know how to inherit richsourcefunction custom reading Mysql to do increment?
猜你喜欢

Jianzhi offer 04 (implemented in C language)

A little feeling

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

Linked list operation can never change without its roots

uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示

Summary of several job scheduling problems

用数据告诉你高考最难的省份是哪里!

【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法

【Day2】 convolutional-neural-networks

MongoDB数据日期显示相差8小时 原因和解决方案
随机推荐
Pod management
Debug:==42==ERROR: AddressSanitizer: heap-buffer-overflow on address
The bamboo shadow sweeps the steps, the dust does not move, and the moon passes through the marsh without trace -- in-depth understanding of the pointer
Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 2
Differences among opencv versions
Exercise 7-8 converting strings to decimal integers (15 points)
Introduction to tree and binary tree
uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
Servlet基本原理与常见API方法的应用
Work order management system OTRs
Exercise 7-4 find out the elements that are not common to two arrays (20 points)
Idea SSH channel configuration
C language structure to realize simple address book
How to teach yourself to learn programming
Whether a person is reliable or not, closed loop is very important
MongoDB数据日期显示相差8小时 原因和解决方案
Remove linked list elements
Hlk-w801wifi connection
Ruby时间格式转换strftime毫秒匹配格式
Basic data types of MySQL