Number.st
branchjv
changeset 19250 a93b96b49985
parent 19142 ff3923c6ad38
parent 19249 c204b2132ad3
child 19478 1f5aa87f6170
equal deleted inserted replaced
19246:e2c74db9dd10 19250:a93b96b49985
   501     "for VisualWorks compatibiity"
   501     "for VisualWorks compatibiity"
   502 
   502 
   503     ^ Integer readFrom:aStream radix:radix
   503     ^ Integer readFrom:aStream radix:radix
   504 ! !
   504 ! !
   505 
   505 
       
   506 
   506 !Number class methodsFor:'constants'!
   507 !Number class methodsFor:'constants'!
   507 
   508 
   508 decimalPointCharacter 
   509 decimalPointCharacter 
   509     "printed"
   510     "printed"
   510 
   511 
   707     "
   708     "
   708      Integer displayRadix:16. 123456 inspect
   709      Integer displayRadix:16. 123456 inspect
   709      Integer displayRadix:10. 123456 inspect
   710      Integer displayRadix:10. 123456 inspect
   710     "
   711     "
   711 ! !
   712 ! !
       
   713 
   712 
   714 
   713 !Number class methodsFor:'private'!
   715 !Number class methodsFor:'private'!
   714 
   716 
   715 readMantissaAndScaleFrom:aStream radix:radix
   717 readMantissaAndScaleFrom:aStream radix:radix
   716     "helper for readFrom: -
   718     "helper for readFrom: -
   782      Abstract subclasses must redefine again."
   784      Abstract subclasses must redefine again."
   783 
   785 
   784     ^ self == Number
   786     ^ self == Number
   785 ! !
   787 ! !
   786 
   788 
       
   789 
   787 !Number methodsFor:'Compatibility-Squeak'!
   790 !Number methodsFor:'Compatibility-Squeak'!
   788 
   791 
   789 asSmallAngleDegrees
   792 asSmallAngleDegrees
   790     "Return the receiver normalized to lie within the range (-180, 180)"
   793     "Return the receiver normalized to lie within the range (-180, 180)"
   791 
   794 
   930 !
   933 !
   931 
   934 
   932 stringForReadout
   935 stringForReadout
   933     ^ self rounded printString
   936     ^ self rounded printString
   934 ! !
   937 ! !
       
   938 
   935 
   939 
   936 !Number methodsFor:'coercing & converting'!
   940 !Number methodsFor:'coercing & converting'!
   937 
   941 
   938 i
   942 i
   939     "return a complex number, with the receiver as imaginary part, 0 as real part"
   943     "return a complex number, with the receiver as imaginary part, 0 as real part"
  1343     "return the natural logarithm of myself.
  1347     "return the natural logarithm of myself.
  1344      Raises an exception, if the receiver is less or equal to zero."
  1348      Raises an exception, if the receiver is less or equal to zero."
  1345 
  1349 
  1346     (self isLimitedPrecisionReal not
  1350     (self isLimitedPrecisionReal not
  1347     or:[self generality < 1.0 generality]) ifTrue:[
  1351     or:[self generality < 1.0 generality]) ifTrue:[
  1348         ^ self asFloat ln.
  1352         ^ self asLongFloat ln.
  1349     ].
  1353     ].
  1350     ^ self ln_withAccuracy:self epsilon
  1354     ^ self ln_withAccuracy:self epsilon
       
  1355 
       
  1356     "
       
  1357         (10 raisedTo:1000) ln
       
  1358     "
  1351 !
  1359 !
  1352 
  1360 
  1353 log
  1361 log
  1354     "return log base 10 of the receiver.
  1362     "return log base 10 of the receiver.
  1355      Alias for log:10."
  1363      Alias for log:10."
  1360 log10
  1368 log10
  1361     "return log base 10 of the receiver"
  1369     "return log base 10 of the receiver"
  1362 
  1370 
  1363     (self isLimitedPrecisionReal not
  1371     (self isLimitedPrecisionReal not
  1364     or:[self generality < 1.0 generality]) ifTrue:[
  1372     or:[self generality < 1.0 generality]) ifTrue:[
  1365         ^ self asFloat log10.
  1373         ^ self asLongFloat log10.
  1366     ].
  1374     ].
  1367     ^ self log:10
  1375     ^ self log:10
       
  1376 
       
  1377     "
       
  1378         (10 raisedTo:1000) log10
       
  1379     "
  1368 !
  1380 !
  1369 
  1381 
  1370 log:aNumber
  1382 log:aNumber
  1371     "return log base aNumber of the receiver.
  1383     "return log base aNumber of the receiver.
  1372      This will usually return a float value"
  1384      This will usually return a float value"
  1375 
  1387 
  1376     "
  1388     "
  1377       1000 log:10
  1389       1000 log:10
  1378       9 log:3
  1390       9 log:3
  1379       (1000 log:10) floor
  1391       (1000 log:10) floor
       
  1392       (10 raisedTo:1000) log:10
  1380     "
  1393     "
  1381 !
  1394 !
  1382 
  1395 
  1383 raisedTo:aNumber
  1396 raisedTo:aNumber
  1384     "return the receiver raised to aNumber"
  1397     "return the receiver raised to aNumber"
  1473     "the minimum possible value taking me as a measurement with possible error; 
  1486     "the minimum possible value taking me as a measurement with possible error; 
  1474      as I am exact, thats myself"
  1487      as I am exact, thats myself"
  1475 
  1488 
  1476     ^ self
  1489     ^ self
  1477 ! !
  1490 ! !
  1478 
       
  1479 
       
  1480 
       
  1481 
       
  1482 
  1491 
  1483 !Number methodsFor:'printing & storing'!
  1492 !Number methodsFor:'printing & storing'!
  1484 
  1493 
  1485 displayOn:aGCOrStream
  1494 displayOn:aGCOrStream
  1486     "return a string to display the receiver.
  1495     "return a string to display the receiver.
  2657 
  2666 
  2658     "Created: / 28.10.1998 / 17:14:56 / cg"
  2667     "Created: / 28.10.1998 / 17:14:56 / cg"
  2659     "Modified: / 5.11.2001 / 17:54:22 / cg"
  2668     "Modified: / 5.11.2001 / 17:54:22 / cg"
  2660 ! !
  2669 ! !
  2661 
  2670 
       
  2671 
  2662 !Number class methodsFor:'documentation'!
  2672 !Number class methodsFor:'documentation'!
  2663 
  2673 
  2664 version
  2674 version
  2665     ^ '$Header$'
  2675     ^ '$Header$'
  2666 !
  2676 !