0

I have made a function in C to calculate large numbers for my future project,
because with the average calculators it's an impossible task.

Is that function working properly?
I would like to know that how far am I from the correct sum.

Factorial
65536! = 5.162948523097533 e +287193

Power
65536 ^ 65536 = 6.741140125499081 e +315652

Thank you!

3
Contributors
3
Replies
56
Views
3 Years
Discussion Span
Last Post by vegaseat
1

Python says 5.16294852309750916500022794327 e287193 and 6.74114012549907340226906510470 e315652. For example

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.misc import factorial
>>> x = factorial(65536, exact=True)
>>> s = str(x)
>>> s[-1]
'0'
>>> s[:30]
'516294852309750916500022794327'
>>> len(s)
287194
>>> 
>>> x = 65536 ** 65536
>>> s = str(x)
>>> s[-1]
'6'
>>> s[:30]
'674114012549907340226906510470'
>>> len(s)
315653

Edited by Gribouillis

0

Thank you!
I'm absolutely satisfied with the precision of my 64 bit double from Microsoft.
Multiplying then dividing thousands of times and still there is a relatively small loss... (RELATIVELY!)
Thanks again!

1

Another way to look at this ...

''' mpm_stuff.py 
comparing Python module mpmath result to C 64bit double results
'''

from mpmath import *

# convert to mpmath float
x = mpf(65536)

# set precision
mp.dps = 16

print("Factorial of 65536:")
print(fac(x))
print("5.162948523097533e+287193  (C)")
print("65536 to the Power of 65536:")
print(x**x)
print("6.741140125499081e+315652  (C)")


''' result ...
Factorial of 65536:
5.162948523097509e+287193
5.162948523097533e+287193  (C)
65536 to the Power of 65536:
6.741140125499073e+315652
6.741140125499081e+315652  (C)
'''

I would say you are close!

Votes + Comments
yes!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.