Procedure Print_Pi (Digit_Count : Positive ) isĪda. Return Comp (LFT' (Q => Ten, R => -Ten * N, S => Zero, T => One ), T ) To_Big_Integer (Extr (T, Four ) ) įunction Prod (T : LFT N : Big_Integer ) return LFT is To_Big_Integer (Extr (T, Three ) ) įunction Safe (T : LFT N : Big_Integer ) return Boolean is
S,įunction Next (T : LFT ) return Big_Integer is Return LFT' (Q => One, R => Zero, S => Zero, T => One ) įunction Comp (T1, T2 : LFT ) return LFT is Set_Numerator (Item => Result,īig_Rationals. ((fromInteger s) * x + (fromInteger t))īig_Rationals. extr (q,r,s,t) x = ((fromInteger q) * x + (fromInteger r)) / type LFT = (Integer, Integer, Integer, Integerįunction Extr (T : LFT X : Big_Integer ) return Big_Rational is
Ten : constant Big_Integer := Int_To_Big. To_Big_Integer ( 3 ) įour : constant Big_Integer := Int_To_Big. Three : constant Big_Integer := Int_To_Big. Two : constant Big_Integer := Int_To_Big. One : constant Big_Integer := Int_To_Big. Zero : constant Big_Integer := Int_To_Big.
Uses same algorithm as Go solution, from pi_digits.adb with Ada.
UNPK XDEC,PACKED packed decimal to zoned printable LOOPI2 C R6,=A(NBUF) do i=2 to hbound(buf)ĬVD R2,PACKED convert v to packed decimal UNPK PG(1),PACKED packed decimal to zoned printable LOOPI1 C R6,=A(NBUF) do i=1 to hbound(buf)ĬVD R1,PACKED convert buf(1) to packed decimal
The program uses one ASSIST macro (XPRNT) to keep the code as short as possible.