Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

C++ how to customize API function to realize multiplication algorithm of large numbers

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "C++ how to customize the API function to achieve large multiplication algorithm", the content is easy to understand, well-organized, I hope it can help you solve your doubts, the following let the editor lead you to study and learn about "C++ how to customize the API function to achieve large number multiplication algorithm" this article.

Ordinary multiplication calculation can be solved with int, long and double, but sometimes the number that needs to be processed is too large, resulting in overflow. The following is the algorithm for realizing positive integer AbeliB of any length, that is, multiplication of large numbers. This algorithm is relatively simple and easy to understand. The idea is as follows:

1. Use the char array an and b to save the input numbers An and B in the main function.

2. multiply each bit of the string array an and b, like the vertical multiplication learned in primary school, the result is saved in the string array s, but does not carry out carry processing; 3, carry each bit of the string array s

4. Assign the string array s to the char array c and return the result.

Char version:

/ / multiply large numbers to realize the large number AbeliBchar * getMultiplyValue (char a [], char b []) / / Parameter a: array name of char type array a; parameter b: array name of char type array b {int iChronomy cbrec; char * c; ca=strlen (a); / / find the length of the string array a cb=strlen (b); / / find the length of the string array b cs=ca+cb; s=new int [cs]; c=new char [cs]; / / initialize the for.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report