eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Infinity':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Infinity


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--ArithmeticValue
         |
         +--Number
            |
            +--MetaNumber
               |
               +--Infinity
                  |
                  +--Infinity::NegativeInfinity
                  |
                  +--Infinity::PositiveInfinity

Package:
stx:libbasic
Category:
Magnitude-Numbers
Version:
rev: 1.33 date: 2023/09/16 09:16:51
user: cg
file: Infinity.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


I have two instances representing positive and negative infinity.
These are singletons used by non-floats (which have individual Inf representations).

Claus: fixed some minor bugs (args to errorUndefinedResult:) and some wrong comments.
       Changed retry:coercing: to match ST/X's way of doing this

Instance Variables :-

copyright

This is a Manchester Goodie. It is distributed freely on condition that you observe these conditions in respect of the whole Goodie, and on any significant part of it which is separately transmitted or stored: * You must ensure that every copy includes this notice, and that source and author(s) of the material are acknowledged. * These conditions must be imposed on anyone who receives a copy. * The material shall not be used for commercial gain without the prior written consent of the author(s). For more information about the Manchester Goodies Library (from which this file was distributed) send e-mail: To: goodies-lib@cs.man.ac.uk Subject: help This is an additional goody-class, which is NOT covered by the ST/X license. It has been packaged with the ST/X distribution to make your live easier instead. NO WARRANTY.

info

NAME infinity AUTHOR manchester FUNCTION Provides a class of infinities ST-VERSION 2.2 PREREQUISITES CONFLICTS DISTRIBUTION world VERSION 1 DATE 22 Jan 1989 SUMMARY This is a set of changes that implements infinity in the Number hierarchy. I obtained the original changes from the author of an article in comp.lang.smalltalk. I have just installed it in my image and I have found two small omissions which are corrected in what is below; there might be others. Arithmetic between infinities is not defined but magnitude comparisons are implemented.

Class protocol:

class initialization
o  initialize
initialize my two singleton instances

Usage example(s):

     Infinity initialize

errors
o  errorUndefinedResult: messageSelector from: aReceiver

instance creation
o  negative
Return the unique instance of negative infinity

Usage example(s):

     Infinity negative negated
     Infinity negative abs
     Infinity positive = Float infinity
     Infinity negative = Float negativeInfinity  
     Infinity negative = Float infinity  

o  negative: aBoolean
Return either instance of negative infinity

o  new
only my two singleton instances are allowed;
get either via Infinity positive or Infinity negative

o  positive
Return the unique instance of positive infinity

queries
o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.


Instance protocol:

arithmetic
o  * aNumber
Multiply the receiver by the argument and answer with the result.

o  + aNumber
Add the receiver and the argument and answer with the result.

o  - aNumber
Subtract aNumber from the receiver and answer the result.

o  / aNumber
Divide the receiver by the argument and answer the result.

coercing & converting
o  generality
Infinities are more general than scalars, but not more general than
vectors (e.g. Points)

comparing
o  < aNumber
Positive infinity is greater than any number other than positive infinity.
Analogously, negative infinity is less than any other number other
than negative infinity

Usage example(s):

     Infinity positive < 0              
     Infinity positive < 1000           
     Infinity positive < -1000          

     Infinity positive < Infinity positive 
     Infinity positive < Infinity negative 

     0 < Infinity positive                 
     1000 < Infinity positive              
     -1000 < Infinity positive             
     Infinity negative < Infinity positive 

     Infinity negative < 0                     
     Infinity negative < 1000                  
     Infinity negative < -1000                 

     Infinity negative < Infinity negative     
     Infinity negative < Infinity positive     

     0 < Infinity negative                     
     1000 < Infinity negative                  
     -1000 < Infinity negative                 
     Infinity negative < Infinity positive     

o  = aNumber
return true, if the argument represents the same numeric value
as the receiver, false otherwise.

o  > aNumber
Positive infinity is greater than any number other than positive infinity.
Analogously, negative infinity is less than any other number other
than negative infinity

Usage example(s):

     Infinity positive > 0                     
     Infinity positive > 1000                  
     Infinity positive > -1000                 

     Infinity positive > Infinity positive     
     Infinity positive > Infinity negative     

     0 > Infinity positive                     
     1000 > Infinity positive                  
     -1000 > Infinity positive                 
     Infinity negative > Infinity positive     

     Infinity negative > 0                     
     Infinity negative > 1000                  
     Infinity negative > -1000                 

     Infinity negative > Infinity negative     
     Infinity negative > Infinity positive     

     0 > Infinity negative                     
     1000 > Infinity negative                  
     -1000 > Infinity negative                 
     Infinity negative > Infinity positive     

double dispatching
o  differenceFromSomeNumber: aNumber
Sent from aNumber-self, if aNumber does not know how to handle this

o  equalFromSomeNumber: aNumber
Sent from aNumber = self, if aNumber does not know how to handle this.
Return true if aNumber = self.

o  lessFromSomeNumber: aNumber
Sent from aNumber < self, if aNumber does not know how to handle this.
Return true if aNumber < self.

o  productFromSomeNumber: aNumber
Sent from aNumber*self, if aNumber does not know how to handle this

o  quotientFromSomeNumber: aNumber
Return the quotient of the argument, aNumber and the receiver.
Sent when aNumber does not know how to divide by the receiver.

o  sumFromSomeNumber: aNumber
Sent from aNumber+self, if aNumber does not know how to handle this

errors
o  errorUndefinedResult: messageSelector

testing
o  isFinite
return true, if the receiver is a finite float (not NaN and not +/-INF)

o  isInfinite
return true, if the receiver is an infinite number (+Inf or -Inf)


Private classes:

    NegativeInfinity
    PositiveInfinity

Examples:


1 + Infinity positive   
Infinity positive + 1     
Infinity positive + Infinity positive     

Infinity negative - 1                   
Infinity negative + Infinity negative   
Infinity negative + Infinity negative   

Infinity negative negated              
Infinity positive negated              

Infinity positive > Infinity negative  
Infinity negative > Infinity positive  

Infinity negative + Infinity positive   -> raises an error
Infinity negative - Infinity negative   -> raises an error


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 01:04:36 GMT