Subject: Re: handling small numbers (fwd)

From: Tim Menzies <[email-masked]>
Date: Fri, 5 May 2000 08:36:42 -0400 (EDT)

no- you did not misread my email. its
just that i'm dealing with numbers like
i've never dealt with ever before. 

e.g.

:- gcd(453476,200000000000000000,X).  

ERROR: mod/2: Type error: `integer'
expected, found `2e+17' 

On Fri, 5 May 2000, Nicos Angelopoulos wrote: ^
Exception: (7) _G433 is 453476 mod 2e+17 ? creep
Exception: (6) gcd(453476, 2e+17, _G336) ? creep    

FYI: jan's suggestion of using the mp package is looking very nice:

e.g. 

sin(1) =
8.414709848078965066525023216302989996225630607983710656727517099919104
04391239668948639743543052695854349037907920674293259118920991898881193410327729
21240948079195582676660699990776401197840878273256634748480287029865615701796245
53948935729246701270864862810533820305613772182038684496677616742662390133827533
97956764255565477963989764824328690275696429120630058303651523031278255289853264
85139819345213597095596206217211481444178105760107567413664805500891672660580414
00780623930703718779562612888046360817345246563914202524041877634207492069520077
13347809814279021452682556632082335215441609164420905892987022473384460448972371
251133317506073634699302844735810079291200202659412415126620952595874251175337087492593254312884809556866051078517582511869743720385823007456578930926179262596598959263171353537749171344569239622804719541228872179012544754202936314584628942573396434759277046755771338787054191726311578122212122636285638369371834389637011948544963823536999372784061690865542882471967910032755340865477304779849816069050488719291254057550866001160430854554756521313852165957466093649409393611586053686115621587915683228292665349787708198897771039656835511684547368843121066334813115193079624919137850746695248115843752319314709320702076116605353506495619432468381250289448986380805512539222281775960477741246451064979204340417810102954638026604886680160342968584043559242547309716989681211754879410791177892651542780992122920411763245657438323940991977835053616461635623418935101768418701066761599264437861316697039217212248461060733855778935011515462844053499174812262025557447220798634969101085035984420813236761766347322111313928267216347462136879576376796415181546012484553272857219812845483830823529492047773103199217003376257535521127667925612233913666812931802716835552275907290232665047428967094960729128314358607589418117382481918794239067211149417335511002753406137770718405072092879
832488518089052258718443914730326786116738567617183536054860403139225412142471605535113264484351634337252245217316483607541582181608724294208873344570652666812868480944199782280901893628882426870732488084907786298015938355516748235294599984613540053146352
85350938177051730555489913301208984611555234114650735523082222050542319345759232018623148086517006826847456257805658225201500535773494764356150063348831701253071510538170487328913854238696217256894541268147313078992E-1
Using 10000 bits of precision
Press RETURN ...                                

Nicos wrote>>>
> 	for the little i know, 
> 	the standard algorithm is the Euclidean one, 
> 
> 	here is my trivial implementation of it 
> 
> 	i have used it extensively with very large quotients 
> 	and it seems to cope well
> 
> 
> 	i think gcd/2 sounds like a good candidate for
> 	a built-in function
> 
> 
> ?- statistics( cputime, Start ), gcd(2,200000,X), statistics( cputime, End
> ).
> 
> Start = 0.16
> X = 2
> End = 0.16 ;
> 
> No
> ?- 
>  
> 
> 	hope i didnt misread your email,
> 
> 
> nicos
> 
> 
> ++++
> 
> 
> 
> gcd( M, N, C ) :-
>         ( N =:= 0 -> C is M
>                   ;  NewN is M mod N,
>                      gcd( N, NewN, C )
>         ).
> 
> 
> 
> 
> ----------------
> * To UNSUBSCRIBE, please use the HTML form at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
> 
> or send mail to [email-masked] using the Subject: "unsubscribe"
> (without the quotes) and *no* message body.
> 
> ** An ARCHIVE of this list is maintained at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/
> 
> 

-- 
[email-masked]; http://www.tim.menzies.com     PH  +1-304-367-8447
NASA, 100 University Dr,Fairmont WV, 26554,USA  FAX +1-304-367-8211
 
"Science is what happens when preconception meets verification."