ArithmeticValue.st
changeset 12578 6cb12eb8eb59
parent 12576 47985f127034
child 12760 6482afd031af
equal deleted inserted replaced
12577:a3224998ea6c 12578:6cb12eb8eb59
   201      Abstract subclasses must redefine again."
   201      Abstract subclasses must redefine again."
   202 
   202 
   203     ^ self == ArithmeticValue
   203     ^ self == ArithmeticValue
   204 ! !
   204 ! !
   205 
   205 
   206 !ArithmeticValue methodsFor:'arithmethic destructive'!
       
   207 
       
   208 *= aNumber
       
   209     "Return the product of self multiplied by aNumber.
       
   210      The receiver MAY, but NEED NOT be changed to contain the product.
       
   211      So this method must be used as: 'a := a *= 5'.
       
   212      This method can be redefined for constructed datatypes to do optimisations"
       
   213 
       
   214     ^ self * aNumber
       
   215 
       
   216     "Created: / 28.4.1999 / 11:46:11 / stefan"
       
   217     "Modified: / 28.4.1999 / 11:53:28 / stefan"
       
   218 !
       
   219 
       
   220 += aNumber
       
   221     "Return the sum of self and aNumber.
       
   222      The receiver MAY, but NEED NOT be changed to contain the sum.
       
   223      So this method must be used as: 'a := a += 5'.
       
   224      This method can be redefined for constructed datatypes to do optimisations"
       
   225 
       
   226     ^ self + aNumber
       
   227 
       
   228     "Created: / 28.4.1999 / 10:13:41 / stefan"
       
   229     "Modified: / 28.4.1999 / 11:54:11 / stefan"
       
   230 !
       
   231 
       
   232 -= aNumber
       
   233     "Return the difference of self and aNumber.
       
   234      The receiver MAY, but NEED NOT be changed to contain the difference.
       
   235      So this method must be used as: 'a := a -= 5'.
       
   236      This method can be redefined for constructed datatypes to do optimisations"
       
   237 
       
   238     ^ self - aNumber
       
   239 
       
   240     "Created: / 28.4.1999 / 10:13:58 / stefan"
       
   241     "Modified: / 28.4.1999 / 11:54:37 / stefan"
       
   242 !
       
   243 
       
   244 /= aNumber
       
   245     "Return the quotient of self and aNumber.
       
   246      The receiver MAY, but NEED NOT be changed to contain the quotient.
       
   247      So this method must be used as: 'a := a /= 5'.
       
   248      This method can be redefined for constructed datatypes to do optimisations"
       
   249 
       
   250     ^ self / aNumber
       
   251 
       
   252     "Created: / 28.4.1999 / 11:46:22 / stefan"
       
   253     "Modified: / 28.4.1999 / 11:55:06 / stefan"
       
   254 !
       
   255 
       
   256 div2
       
   257     "Return the quotient of self divided by 2.
       
   258      The receiver MAY, but NEED NOT be changed to contain the result.
       
   259      So this method must be used as: 'a := a div2.
       
   260      This method can be redefined for constructed datatypes to do optimisations"
       
   261 
       
   262     ^ self // 2
       
   263 
       
   264     "Created: / 28.4.1999 / 10:12:44 / stefan"
       
   265     "Modified: / 28.4.1999 / 11:56:09 / stefan"
       
   266 !
       
   267 
       
   268 mul2
       
   269     "Return the product of self multiplied by 2.
       
   270      The receiver MAY, but NEED NOT be changed to contain the result.
       
   271      So this method must be used as: 'a := a mul2.
       
   272      This method can be redefined for constructed datatypes to do optimisations"
       
   273 
       
   274     ^ self * 2
       
   275 
       
   276     "Created: / 28.4.1999 / 10:12:55 / stefan"
       
   277     "Modified: / 28.4.1999 / 11:56:38 / stefan"
       
   278 ! !
       
   279 
       
   280 !ArithmeticValue methodsFor:'arithmetic'!
   206 !ArithmeticValue methodsFor:'arithmetic'!
   281 
   207 
   282 * something
   208 * something
   283     "return the product of the receiver and the argument."
   209     "return the product of the receiver and the argument."
   284 
   210 
   397 	self isZero ifTrue:[^ self class NaN].
   323 	self isZero ifTrue:[^ self class NaN].
   398 	self negative ifTrue:[^ self class negativeInfinity].
   324 	self negative ifTrue:[^ self class negativeInfinity].
   399 	^ self class infinity.
   325 	^ self class infinity.
   400     ].
   326     ].
   401     ^ self / aNumber
   327     ^ self / aNumber
       
   328 ! !
       
   329 
       
   330 !ArithmeticValue methodsFor:'arithmetic destructive'!
       
   331 
       
   332 *= aNumber
       
   333     "Return the product of self multiplied by aNumber.
       
   334      The receiver MAY, but NEED NOT be changed to contain the product.
       
   335      So this method must be used as: 'a := a *= 5'.
       
   336      This method can be redefined for constructed datatypes to do optimisations"
       
   337 
       
   338     ^ self * aNumber
       
   339 
       
   340     "Created: / 28.4.1999 / 11:46:11 / stefan"
       
   341     "Modified: / 28.4.1999 / 11:53:28 / stefan"
       
   342 !
       
   343 
       
   344 += aNumber
       
   345     "Return the sum of self and aNumber.
       
   346      The receiver MAY, but NEED NOT be changed to contain the sum.
       
   347      So this method must be used as: 'a := a += 5'.
       
   348      This method can be redefined for constructed datatypes to do optimisations"
       
   349 
       
   350     ^ self + aNumber
       
   351 
       
   352     "Created: / 28.4.1999 / 10:13:41 / stefan"
       
   353     "Modified: / 28.4.1999 / 11:54:11 / stefan"
       
   354 !
       
   355 
       
   356 -= aNumber
       
   357     "Return the difference of self and aNumber.
       
   358      The receiver MAY, but NEED NOT be changed to contain the difference.
       
   359      So this method must be used as: 'a := a -= 5'.
       
   360      This method can be redefined for constructed datatypes to do optimisations"
       
   361 
       
   362     ^ self - aNumber
       
   363 
       
   364     "Created: / 28.4.1999 / 10:13:58 / stefan"
       
   365     "Modified: / 28.4.1999 / 11:54:37 / stefan"
       
   366 !
       
   367 
       
   368 /= aNumber
       
   369     "Return the quotient of self and aNumber.
       
   370      The receiver MAY, but NEED NOT be changed to contain the quotient.
       
   371      So this method must be used as: 'a := a /= 5'.
       
   372      This method can be redefined for constructed datatypes to do optimisations"
       
   373 
       
   374     ^ self / aNumber
       
   375 
       
   376     "Created: / 28.4.1999 / 11:46:22 / stefan"
       
   377     "Modified: / 28.4.1999 / 11:55:06 / stefan"
       
   378 !
       
   379 
       
   380 div2
       
   381     "Return the quotient of self divided by 2.
       
   382      The receiver MAY, but NEED NOT be changed to contain the result.
       
   383      So this method must be used as: 'a := a div2.
       
   384      This method can be redefined for constructed datatypes to do optimisations"
       
   385 
       
   386     ^ self // 2
       
   387 
       
   388     "Created: / 28.4.1999 / 10:12:44 / stefan"
       
   389     "Modified: / 28.4.1999 / 11:56:09 / stefan"
       
   390 !
       
   391 
       
   392 mul2
       
   393     "Return the product of self multiplied by 2.
       
   394      The receiver MAY, but NEED NOT be changed to contain the result.
       
   395      So this method must be used as: 'a := a mul2.
       
   396      This method can be redefined for constructed datatypes to do optimisations"
       
   397 
       
   398     ^ self * 2
       
   399 
       
   400     "Created: / 28.4.1999 / 10:12:55 / stefan"
       
   401     "Modified: / 28.4.1999 / 11:56:38 / stefan"
   402 ! !
   402 ! !
   403 
   403 
   404 !ArithmeticValue methodsFor:'coercing & converting'!
   404 !ArithmeticValue methodsFor:'coercing & converting'!
   405 
   405 
   406 coerce:aNumber
   406 coerce:aNumber
  1282 ! !
  1282 ! !
  1283 
  1283 
  1284 !ArithmeticValue class methodsFor:'documentation'!
  1284 !ArithmeticValue class methodsFor:'documentation'!
  1285 
  1285 
  1286 version
  1286 version
  1287     ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.83 2009-12-01 22:08:29 cg Exp $'
  1287     ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.84 2009-12-01 22:11:48 cg Exp $'
  1288 !
  1288 !
  1289 
  1289 
  1290 version_CVS
  1290 version_CVS
  1291     ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.83 2009-12-01 22:08:29 cg Exp $'
  1291     ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.84 2009-12-01 22:11:48 cg Exp $'
  1292 ! !
  1292 ! !
  1293 
  1293 
  1294 ArithmeticValue initialize!
  1294 ArithmeticValue initialize!