我怎样才能繁殖并添加很长的数字? [英] How can I multiply and add very long number ?

查看:114
本文介绍了我怎样才能繁殖并添加很长的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,如果我有一个非常大的数字,我如何在不使用Java中的大整数的情况下添加和乘以这两个数字?





EX:



23478653794837 * 834723742395729





23478653794837 + 834723742395729

My question is, if I have a very large number how can I add and multiply these two numbers without using Big integer in Java??


EX :

23478653794837 * 834723742395729

or
23478653794837 + 834723742395729

推荐答案

引用:

如果我有一个非常大的数字,我如何在不使用Java中的大整数的情况下添加和乘以这两个数字?

if I have a very large number how can I add and multiply these two numbers without using Big integer in Java??

大整数是专门为此目的而完成的。

如果你不想使用大整数,你必须自己构建一组模拟大整数的函数。 />
主要区别在于你不可能像大整数一样高效。

计算C#中整数的因子 [ ^ ]



搜索大汉堡关于它的信息有效。但由于现在每种语言都有一个大整数库,你会被这些答案所淹没。您将不得不优化查询以找到您想要的内容。

Big integers are done especially for this purpose.
If you don't want to use big integers, you will have to build yourself a set of functions that will mimic big integers.
The main difference is that you are unlikely to be as efficient as big integers.
Calculate the Factorial of an Integer in C#[^]

Search for big intergers to informations about it works. But since about every language have now a big integer library, you will be flooded with such answers. You will have to refine the query to find what you want.


一种经典方式:

- 将您的数字视为字符串。

- 乘以和你孩提时的方式相加。

样本:

23 * 45 =(5 * 3 + 5 * 10 * 2)+ (4 * 3 + 4 * 10 * 2)* 10



通过这种方式,你可以乘以&添加所有大整数(如1123222434324323233535345345345345435345454334543 343294324324302432

* 23429492349329433289393895348958934540940958068594695486954864846805486

....

one classical way:
- treat your number like string.
- multiply & add like the way you did when you was a child.
sample:
23*45 = (5*3+ 5*10*2) + (4*3+4*10*2)*10

by this way, you can multiply & add all Big integers (like 1123222434324323233535345345345345435345454334543 343294324324302432
*23429492349329433289393895348958934540940958068594695486954864846805486
....
)


这篇关于我怎样才能繁殖并添加很长的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆