如何找到一些问题c# [英] How to find some problems c#

查看:53
本文介绍了如何找到一些问题c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当n = 1000或更多时,有没有人知道如何在c#中编写程序,以找到值2 * n(在男性2exponent n处)? ???



THNX

Hi,
Does any one know, how to write a program in c#, to find the values 2*n ( it does at men 2exponent n ) when n=1000 or more...???

THNX

推荐答案

您可以使用无限大小的整数类型 System.Numerics.BigInteger

http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx [ ^ ]。



-SA
You can use the unlimited-size integer type System.Numerics.BigInteger:
http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx[^].

—SA


使用基础数学,你可以从mantissant中分别计算指数,这样你就不会被限制在双倍(或长双倍)范围内。



我将使用^作为指数符号,*将具有常规的乘法意义。



With basic mathematics, you can compute the exponent separatly from the mantissant so you won''t be limited to double (or long double) range.

I will uses ^ as the exponent symbol and * will have regular multiplication meaning.

2^n = 10 ^ (n * log 2 / log 10)
    = 10 ^ (n * log 2)





这将给你一个数字。整个部分是指数。并且10指数分数部分给你尾数。



因此2 ^ 1000将给出:



This will give you a number. The whole part is the exponent. And 10 exponent the fractionnal part give you the mantissa.

Thus 2^1000 will give:

2^1000 = 10 ^ (1000 * log 2)
       = 10 ^ 301.0299957
       = 10 ^ 0.0299957 * 10^301
       = 1.071508607 * 10 ^301
       = 1.071508607e301





如果你需要所有数字,那么如SA所提到的,你需要一个大的整数库。



If you need all digits, then as mentionned by SA, you need a large interger library.


这篇关于如何找到一些问题c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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