Fraction.st
changeset 19248 a34488b9f1e6
parent 19241 87e64d3a8410
child 19250 a93b96b49985
child 19259 9e95248432bd
--- a/Fraction.st	Thu Feb 25 12:51:27 2016 +0100
+++ b/Fraction.st	Thu Feb 25 12:51:54 2016 +0100
@@ -15,7 +15,7 @@
 
 Number subclass:#Fraction
 	instanceVariableNames:'numerator denominator'
-	classVariableNames:'FractionOne FractionZero PrintWholeNumbers'
+	classVariableNames:'FractionOne FractionZero PrintWholeNumbers PI_1000'
 	poolDictionaries:''
 	category:'Magnitude-Numbers'
 !
@@ -224,22 +224,51 @@
      The approx. returned here has an error smaller than representable by float instances"
 
     ^ self
-	numerator:314159265358979323846264343
-	denominator:100000000000000000000000000
+        numerator:314159265358979323846264343
+        denominator:100000000000000000000000000
 
-"/    ^ self
-"/        numerator:  314159265358979323846264338327950288419716939937510582097494459
-"/        denominator:100000000000000000000000000000000000000000000000000000000000000
+"
+    ^ self
+        numerator:  314159265358979323846264338327950288419716939937510582097494459
+        denominator:100000000000000000000000000000000000000000000000000000000000000
+"
 
     "
      Fraction pi
      Fraction pi asFloat - Float pi
+     Fraction pi asLongFloat - LongFloat pi
      Float pi
     "
 
     "Modified: / 03-05-2011 / 11:08:46 / cg"
 !
 
+pi1000
+    "return an approximation of the constant pi as Fraction (1024 decimal digits)."
+
+    PI_1000 isNil ifTrue:[
+        PI_1000 := self
+                        numerator:31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632788
+                        denominator:(10 raisedTo:1024).
+    ].
+    ^ PI_1000
+
+"
+    ^ self
+        numerator:  314159265358979323846264338327950288419716939937510582097494459
+        denominator:100000000000000000000000000000000000000000000000000000000000000
+"
+
+    "
+     PI_1000 := nil.
+     Fraction pi1000
+     Fraction pi1000 asLongFloat - LongFloat pi
+     LongFloat pi
+    "
+
+    "Modified: / 03-05-2011 / 11:08:46 / cg"
+!
+
 pi_approximation
     "return an approximation of the constant pi as Fraction.
      The approx. returned is good for 6 valid digits and has an error of less than -2.67-07.