In comp.lang.javascript message <jo5m13hmpej1nb3gbpvf9kt5b9o31rj5ta@4ax.
com>, Tue, 10 Apr 2007 04:50:44, Cogito <no****@nospam.nospamposted:
>I would like to calculate factorial numbers that produce results of
say 100 digits. What is the best way of doing it in Javascript?
Can I define a variable and somehow have control on each of its digits
individually?
Can I multiply two relatively small numbers and determine that there
was a carry?
Perhaps you learned to multiply with pencil and paper at school?
Just represent each number as an array of digits, and implement the
method that you learned. I did that, in Pascal, in the program which
eventually became LONGCALC.PAS, via sig line 3. It's also in <URL:http:
//www.merlyn.demon.co.uk/js-misc0.htm#CDC, functions Add, Twice, Halve,
adequate for a limited situation.
If approximate results will do, see <URL:
http://www.merlyn.demon.co.uk/
js-maths.htm#BF=1000000! = 8.263929417903883e5565708, 10000000! =
1.202421895523417e65657059 .
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm- also batprogs.htm.