x86-64 support
Dmitry Morozovsky
marck at rinet.ru
Mon Apr 28 06:53:18 PDT 2003
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 at rinet.ru ***
------------------------------------------------------------------------
More information about the freebsd-hackers
mailing list