Number.st
changeset 24959 aca1c02bc14a
parent 24950 b05cc09c455e
child 24971 8f4585ee27f8
equal deleted inserted replaced
24958:6a9965ea9d85 24959:aca1c02bc14a
   955     ^ Integer readFrom:aStream radix:radix
   955     ^ Integer readFrom:aStream radix:radix
   956 
   956 
   957     "Modified (comment): / 08-06-2017 / 13:58:36 / mawalch"
   957     "Modified (comment): / 08-06-2017 / 13:58:36 / mawalch"
   958 ! !
   958 ! !
   959 
   959 
   960 
       
   961 !Number class methodsFor:'constants'!
   960 !Number class methodsFor:'constants'!
   962 
   961 
   963 e
   962 e
   964     "return the closest approximation of the irrational number e"
   963     "return the closest approximation of the irrational number e"
   965 
   964 
  1221     "
  1220     "
  1222      Integer displayRadix:16. 123456 inspect
  1221      Integer displayRadix:16. 123456 inspect
  1223      Integer displayRadix:10. 123456 inspect
  1222      Integer displayRadix:10. 123456 inspect
  1224     "
  1223     "
  1225 ! !
  1224 ! !
  1226 
       
  1227 
  1225 
  1228 !Number class methodsFor:'private'!
  1226 !Number class methodsFor:'private'!
  1229 
  1227 
  1230 readMantissaAndScaleFrom:aStream radix:radix
  1228 readMantissaAndScaleFrom:aStream radix:radix
  1231     "helper for readFrom: -
  1229     "helper for readFrom: -
  1330      Abstract subclasses must redefine this again."
  1328      Abstract subclasses must redefine this again."
  1331 
  1329 
  1332     ^ self == Number
  1330     ^ self == Number
  1333 ! !
  1331 ! !
  1334 
  1332 
  1335 
       
  1336 !Number methodsFor:'Compatibility-Squeak'!
  1333 !Number methodsFor:'Compatibility-Squeak'!
  1337 
  1334 
  1338 asSmallAngleDegrees
  1335 asSmallAngleDegrees
  1339     "Return the receiver normalized to lie within the range (-180, 180)"
  1336     "Return the receiver normalized to lie within the range (-180, 180)"
  1340 
  1337 
  1360      (2 asFixedPoint:4) sqrtWithErrorLessThan:0.001
  1357      (2 asFixedPoint:4) sqrtWithErrorLessThan:0.001
  1361     "
  1358     "
  1362 
  1359 
  1363     "Modified: / 25-07-2017 / 15:58:46 / cg"
  1360     "Modified: / 25-07-2017 / 15:58:46 / cg"
  1364 ! !
  1361 ! !
  1365 
       
  1366 
  1362 
  1367 !Number methodsFor:'coercing & converting'!
  1363 !Number methodsFor:'coercing & converting'!
  1368 
  1364 
  1369 i
  1365 i
  1370     "return a complex number, with the receiver as imaginary part, 0 as real part"
  1366     "return a complex number, with the receiver as imaginary part, 0 as real part"
  2094     "multiply the receiver by an integral power of 2.
  2090     "multiply the receiver by an integral power of 2.
  2095      I.e. return self * (2 ^ exp)"
  2091      I.e. return self * (2 ^ exp)"
  2096 
  2092 
  2097     ^ self * (2 raisedTo:exp)
  2093     ^ self * (2 raisedTo:exp)
  2098 
  2094 
       
  2095     "
       
  2096      1.0 ldexp:16  -> 65536.0
       
  2097      1.0 ldexp:100 -> 1.26765060022823E+30
       
  2098      1 * (2 raisedToInteger:100) -> 1267650600228229401496703205376
       
  2099      1 ldexp:200   -> 1606938044258990275541962092341162602522202993782792835301376
       
  2100      1.0 ldexp:200 -> 1.60693804425899E+60
       
  2101     "
       
  2102 
  2099     "Created: / 19-06-2017 / 01:43:35 / cg"
  2103     "Created: / 19-06-2017 / 01:43:35 / cg"
  2100 !
  2104 !
  2101 
  2105 
  2102 ln
  2106 ln
  2103     "return the natural logarithm of myself.
  2107     "return the natural logarithm of myself.
  2315     "the minimum possible value taking me as a measurement with possible error;
  2319     "the minimum possible value taking me as a measurement with possible error;
  2316      as I am exact, that's myself"
  2320      as I am exact, that's myself"
  2317 
  2321 
  2318     ^ self
  2322     ^ self
  2319 ! !
  2323 ! !
  2320 
       
  2321 
       
  2322 
       
  2323 
       
  2324 
  2324 
  2325 !Number methodsFor:'printing & storing'!
  2325 !Number methodsFor:'printing & storing'!
  2326 
  2326 
  2327 displayOn:aGCOrStream
  2327 displayOn:aGCOrStream
  2328     "return a string to display the receiver.
  2328     "return a string to display the receiver.
  3980      7.2345 rounded:3
  3980      7.2345 rounded:3
  3981      7.2348 rounded:3
  3981      7.2348 rounded:3
  3982     "
  3982     "
  3983 ! !
  3983 ! !
  3984 
  3984 
  3985 
       
  3986 !Number class methodsFor:'documentation'!
  3985 !Number class methodsFor:'documentation'!
  3987 
  3986 
  3988 version
  3987 version
  3989     ^ '$Header$'
  3988     ^ '$Header$'
  3990 !
  3989 !