From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 28 06:53:18 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8265037B401 for ; Mon, 28 Apr 2003 06:53:18 -0700 (PDT) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 70ADE43FB1 for ; Mon, 28 Apr 2003 06:53:17 -0700 (PDT) (envelope-from marck@rinet.ru) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.12.9/8.12.9) with ESMTP id h3SDrFeR078590 for ; Mon, 28 Apr 2003 17:53:16 +0400 (MSD) (envelope-from marck@rinet.ru) Date: Mon, 28 Apr 2003 17:53:15 +0400 (MSD) From: Dmitry Morozovsky To: freebsd-hackers@freebsd.org In-Reply-To: <200304280054.h3S0sTi2006266@lurza.secnetix.de> Message-ID: <20030428175010.K77005@woozle.rinet.ru> References: <200304280054.h3S0sTi2006266@lurza.secnetix.de> X-NCC-RegID: ru.rinet MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: x86-64 support X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Apr 2003 13:53:18 -0000 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 *** ------------------------------------------------------------------------