Number.st
changeset 22844 46b2a5dfdfc6
parent 22730 d9060b5c2b4a
child 22859 5475c802f68d
equal deleted inserted replaced
22843:d6201034cacd 22844:46b2a5dfdfc6
   836      Integer displayRadix:16. 123456 inspect
   836      Integer displayRadix:16. 123456 inspect
   837      Integer displayRadix:10. 123456 inspect
   837      Integer displayRadix:10. 123456 inspect
   838     "
   838     "
   839 ! !
   839 ! !
   840 
   840 
   841 
       
   842 !Number class methodsFor:'private'!
   841 !Number class methodsFor:'private'!
   843 
   842 
   844 readMantissaAndScaleFrom:aStream radix:radix
   843 readMantissaAndScaleFrom:aStream radix:radix
   845     "helper for readFrom: -
   844     "helper for readFrom: -
   846      return the mantissa (post-decimal-point digits) from the (character-)stream aStream;
   845      return the mantissa (post-decimal-point digits) from the (character-)stream aStream;
   850      No whitespace is skipped.
   849      No whitespace is skipped.
   851      Errs if no number is available on aStream."
   850      Errs if no number is available on aStream."
   852 
   851 
   853     |nextChar value factor intMantissa scale digit scaleFactor xvalue|
   852     |nextChar value factor intMantissa scale digit scaleFactor xvalue|
   854 
   853 
   855     value := 0.0.
   854     value := 0.
   856     factor := 1.0 / radix.
   855     factor := 1 / radix.
   857     self isAbstract ifFalse:[    
   856     self isAbstract ifFalse:[    
   858         value := self zero.
   857         value := self zero.
   859         factor := self unity / (self coerce:radix).
   858         factor := self unity / (self coerce:radix).
   860     ].
   859     ].
   861     scale := 0.
   860     scale := 0.
   894      Number readMantissaAndScaleFrom:'2'      readStream radix:10.
   893      Number readMantissaAndScaleFrom:'2'      readStream radix:10.
   895      Number readMantissaAndScaleFrom:'234567' readStream radix:10.
   894      Number readMantissaAndScaleFrom:'234567' readStream radix:10.
   896      Number readMantissaAndScaleFrom:'234000' readStream radix:10.
   895      Number readMantissaAndScaleFrom:'234000' readStream radix:10.
   897      Number readMantissaAndScaleFrom:'234'    readStream radix:10.
   896      Number readMantissaAndScaleFrom:'234'    readStream radix:10.
   898      Number readMantissaAndScaleFrom:'000234' readStream radix:10.
   897      Number readMantissaAndScaleFrom:'000234' readStream radix:10.
       
   898      Number readMantissaAndScaleFrom:'01' readStream radix:10.
       
   899      Number readMantissaAndScaleFrom:'001' readStream radix:10.
       
   900      Number readMantissaAndScaleFrom:'0001' readStream radix:10.
   899      Number readMantissaAndScaleFrom:'000000000000000000000000000024' readStream radix:10.
   901      Number readMantissaAndScaleFrom:'000000000000000000000000000024' readStream radix:10.
       
   902      Number readMantissaAndScaleFrom:'0000000000000000000000000000000000000000000024' readStream radix:10.
   900      Number readMantissaAndScaleFrom:'123456789012345678901234567890' readStream radix:10.
   903      Number readMantissaAndScaleFrom:'123456789012345678901234567890' readStream radix:10.
   901 
   904 
   902      Number readMantissaAndScaleFrom:'12345678901234567890' readStream radix:10.
   905      Number readMantissaAndScaleFrom:'12345678901234567890' readStream radix:10.
   903     "
   906     "
   904 
   907 
   930      True is returned for Number here; false for subclasses.
   933      True is returned for Number here; false for subclasses.
   931      Abstract subclasses must redefine this again."
   934      Abstract subclasses must redefine this again."
   932 
   935 
   933     ^ self == Number
   936     ^ self == Number
   934 ! !
   937 ! !
   935 
       
   936 
       
   937 
       
   938 
   938 
   939 !Number methodsFor:'Compatibility-Squeak'!
   939 !Number methodsFor:'Compatibility-Squeak'!
   940 
   940 
   941 asSmallAngleDegrees
   941 asSmallAngleDegrees
   942     "Return the receiver normalized to lie within the range (-180, 180)"
   942     "Return the receiver normalized to lie within the range (-180, 180)"
  1380      10 seconds
  1380      10 seconds
  1381      10 minutes
  1381      10 minutes
  1382     "
  1382     "
  1383 !
  1383 !
  1384 
  1384 
       
  1385 microseconds
       
  1386     "return a TimeDuration representing this number of microseconds."
       
  1387 
       
  1388     ^ TimeDuration fromMicroseconds:self
       
  1389 
       
  1390     "
       
  1391      40 microseconds
       
  1392     "
       
  1393 
       
  1394     "Modified (comment): / 21-09-2017 / 17:37:18 / cg"
       
  1395 !
       
  1396 
  1385 milliSeconds
  1397 milliSeconds
  1386     "return a TimeDuration representing this number of milliseconds
  1398     "return a TimeDuration representing this number of milliseconds
  1387      Same as milliseconds, for compatibility"
  1399      Same as milliseconds, for compatibility"
  1388 
  1400 
  1389     ^ TimeDuration fromMilliseconds:self
  1401     ^ TimeDuration fromMilliseconds:self
  1416     "
  1428     "
  1417      1000 milliseconds
  1429      1000 milliseconds
  1418      10 seconds
  1430      10 seconds
  1419      10 minutes
  1431      10 minutes
  1420     "
  1432     "
       
  1433 !
       
  1434 
       
  1435 nanoseconds
       
  1436     "return a TimeDuration representing this number of nanoseconds."
       
  1437 
       
  1438     ^ TimeDuration fromNanoseconds:self
       
  1439 
       
  1440     "
       
  1441      40 nanoseconds
       
  1442     "
       
  1443 
       
  1444     "Modified (comment): / 21-09-2017 / 17:37:18 / cg"
       
  1445 !
       
  1446 
       
  1447 picoseconds
       
  1448     "return a TimeDuration representing this number of picoseconds."
       
  1449 
       
  1450     ^ TimeDuration fromPicoseconds:self
       
  1451 
       
  1452     "
       
  1453      40 picoseconds
       
  1454     "
       
  1455 
       
  1456     "Modified (comment): / 21-09-2017 / 17:37:18 / cg"
  1421 !
  1457 !
  1422 
  1458 
  1423 seconds
  1459 seconds
  1424     "return a TimeDuration representing this number of seconds"
  1460     "return a TimeDuration representing this number of seconds"
  1425 
  1461 
  3402 
  3438 
  3403     "Created: / 28.10.1998 / 17:14:56 / cg"
  3439     "Created: / 28.10.1998 / 17:14:56 / cg"
  3404     "Modified: / 5.11.2001 / 17:54:22 / cg"
  3440     "Modified: / 5.11.2001 / 17:54:22 / cg"
  3405 ! !
  3441 ! !
  3406 
  3442 
  3407 
       
  3408 !Number class methodsFor:'documentation'!
  3443 !Number class methodsFor:'documentation'!
  3409 
  3444 
  3410 version
  3445 version
  3411     ^ '$Header$'
  3446     ^ '$Header$'
  3412 !
  3447 !