阶乘和指数 [英] factorial and exponent

查看:188
本文介绍了阶乘和指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在涡轮增压器中计算126加速到126的值

C.

我用unsigned long int检查了它但它没有'没帮忙。

那么怎么能计算出这么多数字的价值呢?

技术是什么?

解决方案



" Thomas" < my ******************** @ gmail.comha scritto nel messaggio

news:11 ********* *************@n60g2000hse.googlegr oups.com ...


>我想计算126加值的值涡轮增压中的功率126

C.

我用unsigned long int检查了它但它没有用。

那么如何计算这么大数字的价值?

技术是什么?



1.使用其他编程语言,或者

2.找一个bignum图书馆,或者

3。不要计算它。计算其基数为10的日志。整数部分将

为指数,从小数部分您可以找到

尾数。


< otlog10(126 ** 126)= 126 * log10(126)< / ot>

printf("%fe%d",pow(10,x - floor(x)),( int)floor(x));


其中x是126 * log10(126)。


HTH。


在这篇文章中,我使用^代表to the power of,而不是作为

XOR。


托马斯说:


我想在涡轮增压器中计算126加速到126的值

C.


44329076602207821491972574571700100562486647339617 150064334557177890\

43517106373872170818953941792055669609014893218047 089803712563472169\

06583373889953014265747680923405829337012685381706 863104615274196776\

39132400195465417937691907225941135755503122280004 52759781376

我用unsigned long int检查了它,但它没有帮助。



因为在Turbo C中你可能能够存储在

无符号长整数中的最大值是4294967295,它''不足为奇的是

在这种类型中你不能代表126 ^ 126.


那么如何计算这样的值呢?大数字?

技术是什么?



你会如何手工完成?


为了节省一些工作,你可能会从观察

126 ^ 126 =

(126 ^ 63)^ 2 =

((126 ^ 31)^ 2 * 126)^ 2 =

(((126 ^ 15)^ 2 * 126)^ 2 * 126)^ 2 =

((((126 ^ 7)^ 2 * 126 )^ 2 * 126)^ 2 * 126)^ 2 =

((((((126 ^ 3)^ 2 * 126)^ 2 * 126)^ 2 * 126)^ 2 * 126 )^ 2 =

(((((((126 ^ 2)* 126)^ 2 * 126)^ 2 * 126)^ 2 * 126)^ 2 * 126)^ 2


因此,如果您可以将数字乘以一个数字,并将数字乘以126,

您可以很快得到结果。


参见Knuth的计算机编程艺术第2卷,了解如何将两个任意大数相乘的



或者,学习如何使用具有C绑定的GNU'的GMP包或Miracl




-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。


Thomas写道:


>

我想在
turbo C中计算126加值到126的值。我用无符号检查了它long int但它没有
帮助。那么如何计算这么大数字的价值?

技术是什么?



首先,确定答案是什么。您将需要按

1000位的顺序。可能至少有两个。


-

< http://www.cs.auckland.ac.nz/~pgut001/pubs/ vista_cost.txt>

< http://www.securityfocus.com/columnists/423>

< http://www.aaxnet.com/editor/ edit043.html>

cbfalconer at maineline dot net

-

通过免费的Usenet帐户从 http://www.teranews.com


I want to calculate the value of 126 raise to the power 126 in turbo
C.
I''ve checked it with unsigned long int but it doesn''t help.
So how could one calculate the value of such big numbers?
What''s the technique?

解决方案


"Thomas" <my********************@gmail.comha scritto nel messaggio
news:11**********************@n60g2000hse.googlegr oups.com...

>I want to calculate the value of 126 raise to the power 126 in turbo
C.
I''ve checked it with unsigned long int but it doesn''t help.
So how could one calculate the value of such big numbers?
What''s the technique?

1. Use another programming language, or
2. find a bignum library, or
3. don''t compute it. Compute its base-10 log. The integer part will
be the exponent, and from the fractional part you can find out the
mantissa.

<otlog10(126**126) = 126 * log10(126) </ot>
printf("%fe%d", pow(10, x - floor(x)), (int)floor(x));

where x is 126 * log10(126).

HTH.


In this article, I use ^ to represent "to the power of", rather than as
XOR.

Thomas said:

I want to calculate the value of 126 raise to the power 126 in turbo
C.

44329076602207821491972574571700100562486647339617 150064334557177890\
43517106373872170818953941792055669609014893218047 089803712563472169\
06583373889953014265747680923405829337012685381706 863104615274196776\
39132400195465417937691907225941135755503122280004 52759781376

I''ve checked it with unsigned long int but it doesn''t help.

Since the largest value you are likely to be able to store in an
unsigned long int in Turbo C is 4294967295, it''s hardly surprising that
you can''t represent 126^126 in that type.

So how could one calculate the value of such big numbers?
What''s the technique?

How would you do it by hand?

To save you some work, you''d probably start off by observing that
126^126 =
(126^63)^2 =
((126^31)^2*126)^2 =
(((126^15)^2*126)^2*126)^2 =
((((126^7)^2*126)^2*126)^2*126)^2 =
(((((126^3)^2*126)^2*126)^2*126)^2*126)^2 =
((((((126^2)*126)^2*126)^2*126)^2*126)^2*126)^2

So if you can multiply a number by itself, and multiply a number by 126,
you can get your result quite quickly.

See Knuth''s "The Art of Computer Programming", volume 2, for information
on how to multiply two arbitrarily large numbers.

Alternatively, learn how to use GNU''s GMP package, or Miracl, both of
which have C bindings.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


Thomas wrote:

>
I want to calculate the value of 126 raise to the power 126 in
turbo C. I''ve checked it with unsigned long int but it doesn''t
help. So how could one calculate the value of such big numbers?
What''s the technique?

First, decide what holds the answer. You will need in the order of
1000 bits. Probably at least two of them.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account from http://www.teranews.com


这篇关于阶乘和指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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