FixedPoint.st
changeset 21975 1701bf8eb8e3
parent 21945 fb468e1aac6b
child 24994 24d2a0b0a027
equal deleted inserted replaced
21974:cf76d289d886 21975:1701bf8eb8e3
    15 
    15 
    16 "{ NameSpace: Smalltalk }"
    16 "{ NameSpace: Smalltalk }"
    17 
    17 
    18 Fraction subclass:#FixedPoint
    18 Fraction subclass:#FixedPoint
    19 	instanceVariableNames:'scale'
    19 	instanceVariableNames:'scale'
    20 	classVariableNames:'PrintTruncated Pi Pi_1000'
    20 	classVariableNames:'PrintTruncated Pi Pi_1000 E'
    21 	poolDictionaries:''
    21 	poolDictionaries:''
    22 	category:'Magnitude-Numbers'
    22 	category:'Magnitude-Numbers'
    23 !
    23 !
    24 
    24 
    25 FixedPoint comment:'
    25 FixedPoint comment:'
   313     ^ aNumber asFixedPoint
   313     ^ aNumber asFixedPoint
   314 ! !
   314 ! !
   315 
   315 
   316 !FixedPoint class methodsFor:'constants'!
   316 !FixedPoint class methodsFor:'constants'!
   317 
   317 
       
   318 e
       
   319     "e with roughly 26 valid digits..."
       
   320 
       
   321     |e|
       
   322 
       
   323     E isNil ifTrue:[
       
   324         e := super e.
       
   325         E := e asFixedPoint:(e denominator log10 asInteger - 1)
       
   326     ].
       
   327     ^ E
       
   328 
       
   329     "
       
   330      E := nil.
       
   331      self e
       
   332         -> 2.7182818284590452353602875
       
   333      wolfram:
       
   334            2.718281828459045235360287471352662497757247093699959574966...
       
   335      
       
   336      self e squared    
       
   337      self e reciprocal 
       
   338      1 / self e 
       
   339      self e * 1000000000000000000000000000000000000000000    
       
   340     "
       
   341 
       
   342     "Created: / 03-07-2017 / 17:25:38 / cg"
       
   343 !
       
   344 
   318 pi
   345 pi
   319     "pi with roughly 26 valid digits..."
   346     "pi with roughly 26 valid digits..."
   320 
   347 
   321     |p|
   348     |p|
   322 
   349