Date: Mon, 28 Apr 2003 17:53:15 +0400 (MSD) From: Dmitry Morozovsky <marck@rinet.ru> To: freebsd-hackers@freebsd.org Subject: Re: x86-64 support Message-ID: <20030428175010.K77005@woozle.rinet.ru> In-Reply-To: <200304280054.h3S0sTi2006266@lurza.secnetix.de> References: <200304280054.h3S0sTi2006266@lurza.secnetix.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 28 Apr 2003, Oliver Fromme wrote: OF> You don't need that; the digits of pi can be calculated OF> quite easily with integer math. This snippet is from my OF> signature collection: OF> OF> int f[9800],b,c=9814,g,i;long a=1e4,d,e,h;main(){for(;b=c,c-=14;i=printf( OF> "%04d",e+d/a),e=d%a)while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;} OF> OF> Of course it doesn't comply with style(9), otherwise it OF> wouldn't fit into two lines. Prettifying (de-obfuscating) OF> it to make it style(9)-compliant is left as an exercise to OF> the reader. ;-) OF> OF> Regards OF> Oliver OF> OF> PS: The number of digits is specified by the iteration OF> counter c which starts at 9814 in this case, producing OF> 2800 digits (35 rows on an 80-columns terminal). The OF> counter should be initialized with (digits / 4 + 1) * 14. OF> Don't forget to make the f[] array sufficiently large. In your particular case it does not work, at least under -stable (2.95); moreover, it produces different (both wrong ;) output for -O and -O0 cases. Actually, it's all because f[] isn't large enough ;-) Sincerely, D.Marck [DM5020, DM268-RIPE, DM3-RIPN] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030428175010.K77005>