Number.st
changeset 22115 7781da9ddc6e
parent 22106 9f2406985b6f
child 22119 073225d994bf
equal deleted inserted replaced
22114:94a519213339 22115:7781da9ddc6e
   590     ^ Integer readFrom:aStream radix:radix
   590     ^ Integer readFrom:aStream radix:radix
   591 
   591 
   592     "Modified (comment): / 08-06-2017 / 13:58:36 / mawalch"
   592     "Modified (comment): / 08-06-2017 / 13:58:36 / mawalch"
   593 ! !
   593 ! !
   594 
   594 
       
   595 
   595 !Number class methodsFor:'constants'!
   596 !Number class methodsFor:'constants'!
   596 
   597 
   597 e
   598 e
   598     "return the closest approximation of the irrational number e"
   599     "return the closest approximation of the irrational number e"
   599 
   600 
   831     "
   832     "
   832      Integer displayRadix:16. 123456 inspect
   833      Integer displayRadix:16. 123456 inspect
   833      Integer displayRadix:10. 123456 inspect
   834      Integer displayRadix:10. 123456 inspect
   834     "
   835     "
   835 ! !
   836 ! !
       
   837 
   836 
   838 
   837 !Number class methodsFor:'private'!
   839 !Number class methodsFor:'private'!
   838 
   840 
   839 readMantissaAndScaleFrom:aStream radix:radix
   841 readMantissaAndScaleFrom:aStream radix:radix
   840     "helper for readFrom: -
   842     "helper for readFrom: -
   926      Abstract subclasses must redefine this again."
   928      Abstract subclasses must redefine this again."
   927 
   929 
   928     ^ self == Number
   930     ^ self == Number
   929 ! !
   931 ! !
   930 
   932 
       
   933 
   931 !Number methodsFor:'Compatibility-Squeak'!
   934 !Number methodsFor:'Compatibility-Squeak'!
   932 
   935 
   933 asSmallAngleDegrees
   936 asSmallAngleDegrees
   934     "Return the receiver normalized to lie within the range (-180, 180)"
   937     "Return the receiver normalized to lie within the range (-180, 180)"
   935 
   938 
  1083      (2 asFixedPoint:4) sqrtWithErrorLessThan:0.001
  1086      (2 asFixedPoint:4) sqrtWithErrorLessThan:0.001
  1084     "
  1087     "
  1085 
  1088 
  1086     "Modified: / 25-07-2017 / 15:58:46 / cg"
  1089     "Modified: / 25-07-2017 / 15:58:46 / cg"
  1087 ! !
  1090 ! !
       
  1091 
  1088 
  1092 
  1089 !Number methodsFor:'coercing & converting'!
  1093 !Number methodsFor:'coercing & converting'!
  1090 
  1094 
  1091 i
  1095 i
  1092     "return a complex number, with the receiver as imaginary part, 0 as real part"
  1096     "return a complex number, with the receiver as imaginary part, 0 as real part"
  1712     "/ retry after converting to float
  1716     "/ retry after converting to float
  1713     (self isLimitedPrecisionReal not
  1717     (self isLimitedPrecisionReal not
  1714     or:[self generality < 1.0 generality]) ifTrue:[
  1718     or:[self generality < 1.0 generality]) ifTrue:[
  1715         |f|
  1719         |f|
  1716 
  1720 
  1717         "/ do not make this a longfloat;
  1721         "/ do not make this a LongFloat;
  1718         "/  r will return a longFloat then, and Image roated will fail then...
  1722         "/  r will return a LongFloat then, and Image rotated will fail then...
  1719         (f := self asFloat) isFinite ifTrue:[
  1723         (f := self asFloat) isFinite ifTrue:[
  1720             ^ f sqrt.
  1724             ^ f sqrt.
  1721         ].
  1725         ].
  1722     ].
  1726     ].
  1723     "/ very slow fallback
  1727     "/ very slow fallback
  1724     ^ self sqrt_withAccuracy:self epsilon
  1728     ^ self sqrt_withAccuracy:self epsilon
  1725 
  1729 
  1726     "Modified (format): / 11-07-2017 / 13:32:02 / cg"
  1730     "Modified (format): / 11-07-2017 / 13:32:02 / cg"
       
  1731     "Modified (format): / 26-07-2017 / 12:30:16 / mawalch"
  1727 !
  1732 !
  1728 
  1733 
  1729 timesTwoPower:anInteger
  1734 timesTwoPower:anInteger
  1730     "Return the receiver multiplied by 2 raised to the power of the argument.
  1735     "Return the receiver multiplied by 2 raised to the power of the argument.
  1731      For protocol completeness wrt. Squeak and ST80."
  1736      For protocol completeness wrt. Squeak and ST80."
  3302 
  3307 
  3303     "Created: / 28.10.1998 / 17:14:56 / cg"
  3308     "Created: / 28.10.1998 / 17:14:56 / cg"
  3304     "Modified: / 5.11.2001 / 17:54:22 / cg"
  3309     "Modified: / 5.11.2001 / 17:54:22 / cg"
  3305 ! !
  3310 ! !
  3306 
  3311 
       
  3312 
  3307 !Number class methodsFor:'documentation'!
  3313 !Number class methodsFor:'documentation'!
  3308 
  3314 
  3309 version
  3315 version
  3310     ^ '$Header$'
  3316     ^ '$Header$'
  3311 !
  3317 !