how can I calculate 1000!, the data type doesn't fit such s grate number, please help.

best regards
Posted on 2004-04-30 08:28:24 by mistronr1
Get yourself a big-number library, such as MIRACL (MIRACL has an example to do just what you're talking about).
Posted on 2004-04-30 08:32:06 by death
thanx for you reply

where can I find it please.
Posted on 2004-04-30 08:37:59 by mistronr1
http://indigo.ie/~mscott/ - it isn't exactly written for Assembly use, though. But I guess it should be possible.
Posted on 2004-04-30 09:03:43 by f0dder
This thread might help if you want to code it yourself:

GMP is located at: http://www.swox.com/gmp/
Posted on 2004-04-30 09:05:17 by bitRAKE
thanx guys I'll take a look & come back if I need more help.
Posted on 2004-04-30 11:17:48 by mistronr1

Use Stirling's formula. 1000! ~ 4.02353729204+E2567 Ratch

Posted on 2004-04-30 16:33:53 by Ratch
You can also compute any factorial by adding logarithms.
log(10!) = log(10)+log(9)+log(8)+..+log(2)+log(1)

you get something like: 6.5597630328767937...
Then 10! = 10^6 * inverse_log(0.5597630328767937) = 3.6288 * 10^6

This trick is useful to compute the number of digits of a factorial, if you need to print using a given shape.
Posted on 2004-05-02 11:33:59 by MCoder
Also there exist the gamma function (aproximations, examples, etc).



I check some of the anterior links posted by bitRAKE, there is the gamma function too. Also in the search, I find the book
http://www.google.com.mx/search?q=cache:T4yZemhawUgJ:http://www.math.sfu.ca/~cbm/aands/+&hl=es follow the link to prohosting, or if you whant one without banners http://www.convertit.com/Go/ConvertIt/Reference/AMS55.ASP

Have a nice day or night.
Posted on 2004-05-02 13:12:24 by rea
www.sunderlandstrollers.org.uk/bigfact.exe for a windows program to do it and
www.sunderlandstrollers.org.uk/bigfact.txt for the source code.

Posted on 2004-05-03 18:47:41 by pdixon
Stirlings formula looks pretty nice if you don't need an insanely accuracte number... constant-time too, if I'm not mistaken?
Posted on 2004-05-03 19:07:11 by f0dder
I think the log trick is much better for my needs, coz with the Stirlings formula I still have to compute multiplication of large numbers. my main Problem is store the large number in a variable, I don't have the same Problem if I use log (I guess), I'll try & see what comes out of it.

Thank you
Posted on 2004-05-04 11:56:09 by mistronr1
oops, I accidentaly gave the wrong file name in the post above, it should be:

www.sunderlandstrollers.org.uk/factor3.exe for a windows program to do it and
www.sunderlandstrollers.org.uk/factor3.txt for the source code.


The code linked to does the factorial both ways, it gets an estimate of the final value using sum of logs and then works it out completely using multiplies.

Posted on 2004-05-04 12:04:44 by pdixon

I think the log trick is much better for my needs,

The problem with the log trick is that it becomes pretty unprecise before too long, because the floating-point numbers don't hold enough precision.

You will need some form of bignum if you want to calculate really big factorials. And in this case, Stirling's formula seems good, at least if your bignum library has a non-retarded exponentation routine :)
Posted on 2004-05-04 12:41:50 by f0dder
if you're using bignums then why not just calculate it directly i.e. 1000 * 999 * 998 * ...

using hugs (haskell interpreter) and typing in "product [1..1000]", the answer comes up instantly
Posted on 2004-05-04 13:07:09 by stormix
Thanx paul for the link & thanx f0dder for the advice I'll try both, after all I am still learning how to use the FPU instructions, so I guess this is a good apportunity for me to do so ;)

thanx again everyone for the help, have a nice day..
Posted on 2004-05-04 13:10:54 by mistronr1
Also I write the real link http://www.math.sfu.ca/~cbm/aands/

Aparently in the day that I find that page, the server was shutdown, because I send a mail, I have not much time for read it, but have some interesting things.
Posted on 2004-05-12 12:39:32 by rea

Sorry me but, why would you like to calculate 1000! ? Mathematically, it doesn't make much sense.
Posted on 2004-05-12 12:57:08 by Vortex
Could you not use an extended IEEE 754 (80-bit) value to do it, I believe the exponent goes to +1023?
Posted on 2004-05-12 22:29:22 by x86asm
No because the answer is ~ 4.02353729204+E2567
Posted on 2004-05-13 01:14:53 by bitRAKE