I think you are right, Bob.
In that case, I think it was not necessary to set the precision in the program.
I re-tested the program with large precisions, and now it doesn't seem to affect the elapsed time.
But, I don't understand why the first time I set the precision to 460000 and ran the program, it took 842 seconds.
Dan
'You can set the precision in digits: nu_SetPrecision(%nu_SetPrec_Digits, 460000) 'NUMS math precision in digits ================ N U M S =================== =========================================================== Arbitrary precision floating point and integer math library Free for personal use. Commercial use not allowed. Please read 'NUMS_EULA.txt' (C) 2011 DevOTechS www.devotechs.com =========================================================== Last Modified = 09-02-2011 at 11:15:08 Program = Factorial.tbasic Factorial (n) 100000! = 456575 digits 842,025.731 msecs. Done... Press any key to end program.
"You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields
Dan,
Read the help topic "Disk caching."
With caching turned off, There is a noticable delay on program start-up.
Although I don't believe it would take fourteen minutes. Unless windows was running something in the background.
On my machine, it takes about 40 seconds to calculate 100000!
Bob
I read it, it's good, Bob.
I think Eddy Van Esch made something good.
Concerning the code,
I think "-2" indicates the current directory.nu_SetOption(%nu_Opt_DiskCache, -2) 'Enable disk caching: use Windows temp directory
Dan
"You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields
My experience is that Perl is slow compared to Python and Ruby.
(But, to me, Perl is a lot of fun. It seems there is nothing that is theoretically impossible to do in it.)
' code ------------------------------------------------------------------------------------ # fact.pl use bignum; sub fact { my ($n) = @_; my $fact = 1; my $i; for($i=2;$i<=$n;$i++) {$fact *= $i;} return $fact; } my $n = 20000; my ($user1, $system1) = times; my $f = fact($n); my ($user2, $system2) = times; my $user = $user2 - $user1; print $user; print "\n"; 'output ----------------------------------------------------------------------------------- C:\Users\root\Desktop\Perl>perl -v This is perl, v5.10.1 (*) built for MSWin32-x86-multi-thread Copyright 1987-2009, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. C:\Users\root\Desktop\Perl>perl fact.pl 138.373 C:\Users\root\Desktop\Perl>
Last edited by danbaron; 06-09-2011 at 08:55.
"You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields
Aaaah, come on Dan
Now I'll have to learn Perl!!!
Bob
I think a person could spend a long time trying to master Perl.
I think a lot of ignorant people try to sell it way way short.
http://padre.perlide.org/
http://www.perl.org/books/library.html
"You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields
Thanks, Dan, for the links.
The online books look intriguing.
Bob
zak, I apologize for a totally inappropriate response, please forgive me.
regarding the long compile time, apparently it's due to the version of make,
go to http://sourceforge.net/projects/mingw/files/
click on: MSYS -> make -> make-3.81-3 and download make-3.81-3-msys-1.0.13-bin.tar.lzma and extract to msys\1.0\bin folder.
my compile time for gmp 5.0.2 after having run config was about 10 minutes, make check time was about 12 minutes
Bookmarks