Integer.st
changeset 14796 242490a39283
parent 14767 157f37c1a7f9
child 14967 0f7cf85949b2
child 18027 3621469cc5e8
equal deleted inserted replaced
14795:21ddbafc7a30 14796:242490a39283
   755     ^ BCDConversionErrorSignal
   755     ^ BCDConversionErrorSignal
   756 
   756 
   757     "Modified: / 15.11.1999 / 20:35:20 / cg"
   757     "Modified: / 15.11.1999 / 20:35:20 / cg"
   758 ! !
   758 ! !
   759 
   759 
       
   760 
       
   761 
   760 !Integer class methodsFor:'class initialization'!
   762 !Integer class methodsFor:'class initialization'!
   761 
   763 
   762 initialize
   764 initialize
   763     BCDConversionErrorSignal isNil ifTrue:[
   765     BCDConversionErrorSignal isNil ifTrue:[
   764 	BCDConversionErrorSignal := ConversionError newSignal.
   766 	BCDConversionErrorSignal := ConversionError newSignal.
   814     "
   816     "
   815      Integer displayRadix:16. 123456 inspect
   817      Integer displayRadix:16. 123456 inspect
   816      Integer displayRadix:10. 123456 inspect
   818      Integer displayRadix:10. 123456 inspect
   817     "
   819     "
   818 ! !
   820 ! !
       
   821 
   819 
   822 
   820 !Integer class methodsFor:'prime numbers'!
   823 !Integer class methodsFor:'prime numbers'!
   821 
   824 
   822 flushPrimeCache
   825 flushPrimeCache
   823     "cleanup after using a primeCache"
   826     "cleanup after using a primeCache"
  1137      Abstract subclasses must redefine again."
  1140      Abstract subclasses must redefine again."
  1138 
  1141 
  1139     ^ self == Integer
  1142     ^ self == Integer
  1140 ! !
  1143 ! !
  1141 
  1144 
       
  1145 
  1142 !Integer methodsFor:'Compatibility-Dolphin'!
  1146 !Integer methodsFor:'Compatibility-Dolphin'!
  1143 
  1147 
  1144 & aNumber
  1148 & aNumber
  1145     "return the bitwise-and of the receiver and the argument, anInteger.
  1149     "return the bitwise-and of the receiver and the argument, anInteger.
  1146      Same as bitAnd: - added for compatibility with Dolphin Smalltalk.
  1150      Same as bitAnd: - added for compatibility with Dolphin Smalltalk.
  1251          [repeats timesRepeat: (number asByteArrayOfSize: 1024) ] timeToRun.
  1255          [repeats timesRepeat: (number asByteArrayOfSize: 1024) ] timeToRun.
  1252      )))"
  1256      )))"
  1253 
  1257 
  1254     | bytes |
  1258     | bytes |
  1255 
  1259 
  1256     size < self digitLength ifTrue: [^ self error: 'number too big for ', size asString].
       
  1257     bytes := self digitBytesMSB:true.
  1260     bytes := self digitBytesMSB:true.
       
  1261     size < bytes size ifTrue: [
       
  1262         ^ ConversionError raiseRequestWith:self errorString:'number too big for ', size asString
       
  1263     ].
  1258     ^ (ByteArray new: (size - bytes size)), bytes
  1264     ^ (ByteArray new: (size - bytes size)), bytes
  1259 
  1265 
  1260     "
  1266     "
  1261      123 asByteArrayOfSize:1 #[123]
  1267      123 asByteArrayOfSize:1 #[123]
  1262      123 asByteArrayOfSize:2 #[0 123]
  1268      123 asByteArrayOfSize:2 #[0 123]
  4234     "
  4240     "
  4235 
  4241 
  4236     "Created: / 09-01-2012 / 17:18:06 / cg"
  4242     "Created: / 09-01-2012 / 17:18:06 / cg"
  4237 ! !
  4243 ! !
  4238 
  4244 
       
  4245 
  4239 !Integer methodsFor:'special modulu arithmetic'!
  4246 !Integer methodsFor:'special modulu arithmetic'!
  4240 
  4247 
  4241 add_32:anInteger
  4248 add_32:anInteger
  4242     "return a C-semantic 32bit sum of the receiver and the argument. 
  4249     "return a C-semantic 32bit sum of the receiver and the argument. 
  4243      Both must be either Small- or LargeIntegers.
  4250      Both must be either Small- or LargeIntegers.
  4920 ! !
  4927 ! !
  4921 
  4928 
  4922 !Integer class methodsFor:'documentation'!
  4929 !Integer class methodsFor:'documentation'!
  4923 
  4930 
  4924 version
  4931 version
  4925     ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.274 2013-02-08 13:01:03 cg Exp $'
  4932     ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.275 2013-02-22 11:41:18 stefan Exp $'
  4926 !
  4933 !
  4927 
  4934 
  4928 version_CVS
  4935 version_CVS
  4929     ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.274 2013-02-08 13:01:03 cg Exp $'
  4936     ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.275 2013-02-22 11:41:18 stefan Exp $'
  4930 ! !
  4937 ! !
  4931 
  4938 
  4932 
  4939 
  4933 Integer initialize!
  4940 Integer initialize!