--- a/FixedPoint.st Thu Feb 25 06:43:47 2016 +0100
+++ b/FixedPoint.st Fri Feb 26 06:41:16 2016 +0100
@@ -17,7 +17,7 @@
Fraction subclass:#FixedPoint
instanceVariableNames:'scale'
- classVariableNames:'PI_1000 PrintTruncated'
+ classVariableNames:'PrintTruncated'
poolDictionaries:''
category:'Magnitude-Numbers'
!
@@ -287,9 +287,21 @@
pi
"pi with 1000 valid digits..."
+ ^ self pi1000
+
+ "
+ self pi squared
+ self pi reciprocal
+ 1 / self pi
+ self pi * 1000000000000000000000000000000000000000000
+ "
+!
+
+pi1000
+ "pi with 1000 valid digits..."
+
PI_1000 isNil ifTrue:[
- PI_1000 := self
- readFrom:'3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632788'
+ PI_1000 := super pi1000 asFixedPoint:1024
].
^ PI_1000.
--- a/Fraction.st Thu Feb 25 06:43:47 2016 +0100
+++ b/Fraction.st Fri Feb 26 06:41:16 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.
--- a/Number.st Thu Feb 25 06:43:47 2016 +0100
+++ b/Number.st Fri Feb 26 06:41:16 2016 +0100
@@ -503,6 +503,7 @@
^ Integer readFrom:aStream radix:radix
! !
+
!Number class methodsFor:'constants'!
decimalPointCharacter
@@ -710,6 +711,7 @@
"
! !
+
!Number class methodsFor:'private'!
readMantissaAndScaleFrom:aStream radix:radix
@@ -784,6 +786,7 @@
^ self == Number
! !
+
!Number methodsFor:'Compatibility-Squeak'!
asSmallAngleDegrees
@@ -933,6 +936,7 @@
^ self rounded printString
! !
+
!Number methodsFor:'coercing & converting'!
i
@@ -1345,9 +1349,13 @@
(self isLimitedPrecisionReal not
or:[self generality < 1.0 generality]) ifTrue:[
- ^ self asFloat ln.
+ ^ self asLongFloat ln.
].
^ self ln_withAccuracy:self epsilon
+
+ "
+ (10 raisedTo:1000) ln
+ "
!
log
@@ -1362,9 +1370,13 @@
(self isLimitedPrecisionReal not
or:[self generality < 1.0 generality]) ifTrue:[
- ^ self asFloat log10.
+ ^ self asLongFloat log10.
].
^ self log:10
+
+ "
+ (10 raisedTo:1000) log10
+ "
!
log:aNumber
@@ -1377,6 +1389,7 @@
1000 log:10
9 log:3
(1000 log:10) floor
+ (10 raisedTo:1000) log:10
"
!
@@ -1476,10 +1489,6 @@
^ self
! !
-
-
-
-
!Number methodsFor:'printing & storing'!
displayOn:aGCOrStream
@@ -2659,6 +2668,7 @@
"Modified: / 5.11.2001 / 17:54:22 / cg"
! !
+
!Number class methodsFor:'documentation'!
version