small numbers..

TheIsingGuy
08-13-2009, 05:03 AM
how do I define and use small numbers for computations? on the scale of 10^-30?

e.g.
Program A
implicit none
double precision a,b,c,d
c = (a*b)/(a+b)
d = etc...

End program

The above has an overflow error when I give a,b the values 3.345 * 10^-27

Can anyone help?

Thanks

Ising

davekw7x
08-14-2009, 10:27 AM
how do I define and use small numbers for computations? on the scale of 10^-30? Same advice as with very large numbers: Find an arbitrary precision package.

With mpfun I calculated 500 factorial (1135 decimal digits). I also printed its inverse to 1200 digits:

N= 500 N!=
10 ^ 1134 x 1.220136825991110068701238785423046926253574342803 1928421924
13588385845373153881997605496447502203281863013616 4771482035841633787220781772
00480785205159329285477907571939330603772960859086 2704291745478824249127263443
05670173270769461062802310452644218878789465754777 1498634943677810376442740338
27365397471386477878495438489595537537990423241061 2713269843277457155463099772
02781014561081188373709531016356324432987029563896 6289116589747695720879269288
71281780070265174507768410719624390394322536422605 2349458501299185715012487069
61568141625359056693423813008856249246891564126775 6544818865065938479517753608
94005745238940335798476363944905313062323749066445 0488246650759467358620746379
25184200459369692981022263971952597190945217823331 7569345815085523328207628200
23402626907898342451712006207714640979456116127629 1459512372299133401695523638
50942885592018727433795173014586357570828355780158 7354327688886801203998823847
02151467605445407663535984174430480128938313896881 6394874696588175045069263653
3817505547812864,

N= 500 1.0/N!=
10 ^ -1135 x 8.195802132172396309504761462495484735303103973134 5424185533
37729108316576457454962344089922997503222399984713 5401000229774507564909766192
09305566636409314553527624040945251118901900343120 4869738423954422643123093567
20815556436869783391393506867318943003635954758050 1228575047617204104149255170
36103307741508293639563074471026095521265930433050 7147285587514891373603240624
52309027194252511424844042282734220065452018770488 4364455758790754150079392136
30345325815648205650607215635450304416165689026406 0566028236938485928091064842
92377307477924144410883655688941503503331888787730 2805815040186160648847523749
96340116669239143195526775589797267068302194455331 9913446130373748642677763239
25117455547423697492338621796128506767470500683328 7822315178723296193749892684
31874530325664270602248944607433922828227705573281 2488109899142168181690843214
35440296306260062735880529663858216186704520358267 5163862010380704002809401964
70999796905048383244762429836539784778068154446146 8746227270711828992567523683
45192268432401487390829256127939310174021984898593 4135105366389074318295911259
02797557125783690465886763341391023215430391760888 3065014477772847442874592985
03138819165999141989186488169863319146674522324733 ,

Note that the integer value of the factorial is exact, but mpfun represents and prints it in floating point format so the output doesn't show the 125 trailing zeros.

Regards,

Dave