Infinity.st
author Stefan Vogel <sv@exept.de>
Tue, 28 Apr 2020 14:41:21 +0200
changeset 25372 389daab3ee10
parent 24955 383d5baf43e1
permissions -rw-r--r--
#DOCUMENTATION by stefan class: ReadWriteStream category of: #isEmpty #isReadable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24955
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
     1
"{ Encoding: utf8 }"
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
     2
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
     3
"
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
     4
 This is a Manchester Goodie.  It is distributed freely on condition
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
     5
 that you observe these conditions in respect of the whole Goodie, and on
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
     6
 any significant part of it which is separately transmitted or stored:
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
     7
	* You must ensure that every copy includes this notice, and that
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
     8
	  source and author(s) of the material are acknowledged.
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
     9
	* These conditions must be imposed on anyone who receives a copy.
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    10
	* The material shall not be used for commercial gain without the prior
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    11
	  written consent of the author(s).
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    12
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    13
 For more information about the Manchester Goodies Library (from which 
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    14
 this file was distributed) send e-mail:
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    15
	To: goodies-lib@cs.man.ac.uk
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    16
	Subject: help 
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    17
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    18
 This is an additional goody-class, which is NOT covered by the
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    19
 ST/X license. It has been packaged with the ST/X distribution to
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    20
 make your live easier instead. NO WARRANTY.
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    21
"
7452
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
    22
"{ Package: 'stx:libbasic' }"
1894
b22296ae189f Fixed is now in libbasic
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
    23
18856
8ad83639df20 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16037
diff changeset
    24
"{ NameSpace: Smalltalk }"
8ad83639df20 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16037
diff changeset
    25
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    26
MetaNumber subclass:#Infinity
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
    27
	instanceVariableNames:''
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    28
	classVariableNames:'InfNeg InfPos'
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    29
	poolDictionaries:''
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    30
	category:'Magnitude-Numbers'
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    31
!
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
    32
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    33
Infinity subclass:#NegativeInfinity
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    34
	instanceVariableNames:''
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    35
	classVariableNames:''
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    36
	poolDictionaries:''
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    37
	privateIn:Infinity
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    38
!
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    39
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    40
Infinity subclass:#PositiveInfinity
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    41
	instanceVariableNames:''
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    42
	classVariableNames:''
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    43
	poolDictionaries:''
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    44
	privateIn:Infinity
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    45
!
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    46
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    47
Infinity comment:'I have two instances representing positive and negative infinity.
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
    48
f014922e3b71 Initial revision
claus
parents:
diff changeset
    49
Instance Variables :-
303
3b550c73b036 *** empty log message ***
claus
parents: 265
diff changeset
    50
	positive <Boolean>      :       if true the instance represents positive
3b550c73b036 *** empty log message ***
claus
parents: 265
diff changeset
    51
					infinity. if false, negative infinity'
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
    52
!
f014922e3b71 Initial revision
claus
parents:
diff changeset
    53
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    54
!Infinity class methodsFor:'documentation'!
6501
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    55
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    56
copyright
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    57
"
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    58
 This is a Manchester Goodie.  It is distributed freely on condition
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    59
 that you observe these conditions in respect of the whole Goodie, and on
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    60
 any significant part of it which is separately transmitted or stored:
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    61
	* You must ensure that every copy includes this notice, and that
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    62
	  source and author(s) of the material are acknowledged.
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    63
	* These conditions must be imposed on anyone who receives a copy.
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    64
	* The material shall not be used for commercial gain without the prior
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    65
	  written consent of the author(s).
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    66
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    67
 For more information about the Manchester Goodies Library (from which 
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    68
 this file was distributed) send e-mail:
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    69
	To: goodies-lib@cs.man.ac.uk
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    70
	Subject: help 
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    71
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    72
 This is an additional goody-class, which is NOT covered by the
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    73
 ST/X license. It has been packaged with the ST/X distribution to
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    74
 make your live easier instead. NO WARRANTY.
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    75
"
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    76
!
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    77
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    78
documentation
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    79
"
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    80
    I have two instances representing positive and negative infinity.
6501
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    81
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    82
    Claus: fixed some minor bugs (args to errorUndefinedResult:) and some wrong comments.
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
    83
           Changed retry:coercing: to match ST/X's way of doing this
6501
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    84
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    85
    Instance Variables :-
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    86
"
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    87
!
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    88
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    89
examples
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    90
"
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
    91
    1 + Infinity positive   
6501
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    92
    Infinity positive + 1     
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    93
    Infinity positive + Infinity positive     
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    94
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    95
    Infinity negative - 1                   
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    96
    Infinity negative + Infinity negative   
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
    97
    Infinity negative + Infinity negative   
6501
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
    98
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
    99
    Infinity negative negated              
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   100
    Infinity positive negated              
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   101
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   102
    Infinity positive > Infinity negative  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   103
    Infinity negative > Infinity positive  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   104
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   105
    Infinity negative + Infinity positive   -> raises an error
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   106
    Infinity negative - Infinity negative   -> raises an error
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   107
6501
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   108
"
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   109
!
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   110
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   111
info
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   112
"       
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   113
    NAME            infinity
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   114
    AUTHOR          manchester
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   115
    FUNCTION        Provides a class of infinities
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   116
    ST-VERSION      2.2
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   117
    PREREQUISITES   
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   118
    CONFLICTS
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   119
    DISTRIBUTION    world
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   120
    VERSION         1
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   121
    DATE            22 Jan 1989
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   122
    SUMMARY
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   123
        This is a set of changes that implements infinity in the Number hierarchy.  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   124
        I obtained the original changes from the author of an article in comp.lang.smalltalk.
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   125
        I have just installed it in my image and I have found two small omissions
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   126
        which are corrected in what is below; there might be others.  Arithmetic
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   127
        between infinities is not defined but magnitude comparisons are implemented.
6501
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   128
"
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   129
! !
51344e42c38c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5287
diff changeset
   130
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   131
!Infinity class methodsFor:'instance creation'!
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   132
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   133
negative
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   134
    "Return the unique instance of negative infinity"
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   135
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   136
    ^InfNeg
24955
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   137
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   138
    "
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   139
     Infinity negative negated
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   140
     Infinity negative abs
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   141
     Infinity positive = Float infinity
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   142
     Infinity negative = Float negativeInfinity  
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   143
     Infinity negative = Float infinity  
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   144
    "
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   145
!
f014922e3b71 Initial revision
claus
parents:
diff changeset
   146
16037
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   147
negative:aBoolean
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   148
    "Return either instance of negative infinity"
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   149
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   150
    ^ aBoolean ifTrue:[InfNeg] ifFalse:[InfPos].
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   151
!
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   152
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   153
new
16037
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   154
    "only my two singleton instances are allowed;
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   155
      get either via Infinity positive or Infinity negative"
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   156
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   157
    self shouldNotImplement
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   158
!
f014922e3b71 Initial revision
claus
parents:
diff changeset
   159
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   160
positive
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   161
    "Return the unique instance of positive infinity"
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   162
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   163
    ^InfPos
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   164
! !
f014922e3b71 Initial revision
claus
parents:
diff changeset
   165
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   166
!Infinity class methodsFor:'class initialization'!
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   167
f014922e3b71 Initial revision
claus
parents:
diff changeset
   168
initialize
16037
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   169
    "initialize my two singleton instances"
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   170
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   171
    InfPos := PositiveInfinity basicNew.
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   172
    InfNeg := NegativeInfinity basicNew.
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   173
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   174
    "
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   175
     Infinity initialize
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   176
    "
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   177
! !
f014922e3b71 Initial revision
claus
parents:
diff changeset
   178
18917
d04b3fd93ce3 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18856
diff changeset
   179
!Infinity class methodsFor:'queries'!
d04b3fd93ce3 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18856
diff changeset
   180
d04b3fd93ce3 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18856
diff changeset
   181
isAbstract
d04b3fd93ce3 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18856
diff changeset
   182
    ^ self == Infinity
d04b3fd93ce3 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18856
diff changeset
   183
! !
d04b3fd93ce3 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18856
diff changeset
   184
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   185
!Infinity methodsFor:'arithmetic'!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   186
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   187
* aNumber
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   188
    "Multiply the receiver by the argument and answer with the result."
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   189
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   190
    aNumber isInfinite ifTrue: [
7452
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   191
	self errorUndefinedResult: #*.
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   192
	^ self class NaN.
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   193
    ].
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   194
    ^self
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   195
!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   196
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   197
+ aNumber
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   198
    "Add the receiver and the argument and answer with the result."
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   199
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   200
    (aNumber isInfinite and:[aNumber sign ~~ self sign]) ifTrue: [
7452
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   201
	self errorUndefinedResult: #+.
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   202
	^ self class NaN
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   203
    ].
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   204
    ^self
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   205
!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   206
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   207
- aNumber
21294
001df69aba2d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21213
diff changeset
   208
    "Subtract aNumber from the receiver and answer the result."
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   209
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   210
    (aNumber isInfinite and:[aNumber sign == self sign]) ifTrue: [
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   211
        self errorUndefinedResult: #-.
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   212
        ^ self class NaN
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   213
    ].
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   214
    ^self
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   215
!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   216
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   217
/ aNumber
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   218
    "Divide the receiver by the argument and answer the result."
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   219
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   220
    (aNumber isInfinite or: [aNumber = 0]) ifTrue: [
7452
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   221
	self errorUndefinedResult: #/.
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   222
	^ self class NaN.
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   223
    ].
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   224
    ^self
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   225
! !
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   226
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   227
!Infinity methodsFor:'coercing'!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   228
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   229
generality
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   230
    "Infinities are more general than scalars, but not more general than
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   231
     vectors (e.g. Points)"
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   232
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   233
    ^ 105
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   234
! !
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   235
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   236
!Infinity methodsFor:'comparing'!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   237
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   238
< aNumber
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   239
    "Positive infinity is greater than any number other than positive infinity.
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   240
     Analogously, negative infinity is less than any other number other
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   241
     than negative infinity"
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   242
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   243
    aNumber == self ifTrue: [^false].
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   244
    ^ self positive not
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   245
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   246
    "
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   247
     Infinity positive < 0              
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   248
     Infinity positive < 1000           
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   249
     Infinity positive < -1000          
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   250
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   251
     Infinity positive < Infinity positive 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   252
     Infinity positive < Infinity negative 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   253
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   254
     0 < Infinity positive                 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   255
     1000 < Infinity positive              
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   256
     -1000 < Infinity positive             
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   257
     Infinity negative < Infinity positive 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   258
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   259
     Infinity negative < 0                     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   260
     Infinity negative < 1000                  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   261
     Infinity negative < -1000                 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   262
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   263
     Infinity negative < Infinity negative     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   264
     Infinity negative < Infinity positive     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   265
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   266
     0 < Infinity negative                     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   267
     1000 < Infinity negative                  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   268
     -1000 < Infinity negative                 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   269
     Infinity negative < Infinity positive     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   270
    "
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   271
!
f014922e3b71 Initial revision
claus
parents:
diff changeset
   272
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   273
= aNumber
7471
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   274
    "return true, if the argument represents the same numeric value
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   275
     as the receiver, false otherwise."
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   276
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   277
    aNumber == self ifTrue:[^ true].
12246
e5cc18fff88b changed: #=
Claus Gittinger <cg@exept.de>
parents: 7548
diff changeset
   278
    aNumber isNumber ifFalse:[^ false].
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   279
    "could be another infinity..."
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   280
    aNumber isFinite ifTrue:[^ false].
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   281
    ^ aNumber sign == self sign
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   282
!
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   283
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   284
> aNumber
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   285
    "Positive infinity is greater than any number other than positive infinity.
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   286
     Analogously, negative infinity is less than any other number other
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   287
     than negative infinity"
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   288
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   289
    aNumber == self ifTrue: [^false].
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   290
    ^ self positive
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   291
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   292
    "
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   293
     Infinity positive > 0                     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   294
     Infinity positive > 1000                  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   295
     Infinity positive > -1000                 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   296
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   297
     Infinity positive > Infinity positive     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   298
     Infinity positive > Infinity negative     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   299
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   300
     0 > Infinity positive                     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   301
     1000 > Infinity positive                  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   302
     -1000 > Infinity positive                 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   303
     Infinity negative > Infinity positive     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   304
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   305
     Infinity negative > 0                     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   306
     Infinity negative > 1000                  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   307
     Infinity negative > -1000                 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   308
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   309
     Infinity negative > Infinity negative     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   310
     Infinity negative > Infinity positive     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   311
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   312
     0 > Infinity negative                     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   313
     1000 > Infinity negative                  
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   314
     -1000 > Infinity negative                 
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   315
     Infinity negative > Infinity positive     
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   316
    "
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   317
! !
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   318
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   319
!Infinity methodsFor:'double dispatching'!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   320
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   321
differenceFromSomeNumber:aNumber
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   322
    "Sent from aNumber-self, if aNumber does not know how to handle this"
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   323
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   324
    ^ self negated
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   325
!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   326
21213
6b551315599b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 18917
diff changeset
   327
equalFromSomeNumber:aNumber
6b551315599b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 18917
diff changeset
   328
    "Sent from aNumber = self, if aNumber does not know how to handle this.
6b551315599b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 18917
diff changeset
   329
     Return true if aNumber = self."
6b551315599b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 18917
diff changeset
   330
6b551315599b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 18917
diff changeset
   331
    ^ aNumber isInfinite and:[self sign == aNumber sign]
6b551315599b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 18917
diff changeset
   332
!
6b551315599b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 18917
diff changeset
   333
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   334
lessFromSomeNumber:aNumber
18856
8ad83639df20 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16037
diff changeset
   335
    "Sent from aNumber < self, if aNumber does not know how to handle this.
8ad83639df20 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16037
diff changeset
   336
     Return true if aNumber < self."
7548
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   337
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   338
    aNumber isFinite ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   339
        ^ self positive.
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   340
    ].
Claus Gittinger <cg@exept.de>
parents: 7471
diff changeset
   341
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   342
    ^ Number
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   343
        raise: #undefinedResultSignal
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   344
        receiver: self
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   345
        selector: #lessFromSomeNumber:
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   346
        errorString: 'Cannot compare against NaN'
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   347
!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   348
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   349
productFromSomeNumber:aNumber
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   350
    "Sent from aNumber*self, if aNumber does not know how to handle this"
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   351
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   352
    aNumber sign >= 0 ifTrue:[
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   353
        ^ self
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   354
    ].
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   355
    ^ self negated
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   356
!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   357
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   358
quotientFromSomeNumber:aNumber
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   359
    "Return the quotient of the argument, aNumber and the receiver.
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   360
     Sent when aNumber does not know how to divide by the receiver."
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   361
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   362
    aNumber sign > 0 ifTrue:[
7452
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   363
	^ self
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   364
    ].
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   365
    aNumber sign < 0 ifTrue:[
7452
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   366
	^ self negated
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   367
    ].
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   368
    ^ aNumber realNumber
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   369
!
f014922e3b71 Initial revision
claus
parents:
diff changeset
   370
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   371
sumFromSomeNumber:aNumber
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   372
    "Sent from aNumber+self, if aNumber does not know how to handle this"
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   373
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   374
    ^ self
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   375
! !
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   376
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   377
!Infinity methodsFor:'errors'!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   378
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   379
errorUndefinedResult: messageName
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   380
    ^ Number
7452
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   381
	raise: #undefinedResultSignal
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   382
	receiver: self
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   383
	selector: #lessFromSomeNumber:
224a1764084a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7443
diff changeset
   384
	errorString: 'Undefined result in an Infinity ', messageName
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   385
! !
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   386
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   387
!Infinity methodsFor:'testing'!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   388
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   389
isFinite
24708
a378ebfefa61 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24200
diff changeset
   390
    "return true, if the receiver is a finite float (not NaN and not +/-INF)"
a378ebfefa61 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24200
diff changeset
   391
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   392
    ^false
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   393
!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   394
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   395
isInfinite
24708
a378ebfefa61 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24200
diff changeset
   396
    "return true, if the receiver is an infinite number (+Inf or -Inf)"
a378ebfefa61 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24200
diff changeset
   397
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   398
    ^true
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   399
! !
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   400
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   401
!Infinity::NegativeInfinity methodsFor:'arithmetic'!
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   402
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   403
negated
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   404
    ^ InfPos
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   405
! !
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   406
16037
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   407
!Infinity::NegativeInfinity methodsFor:'comparing'!
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   408
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   409
hash
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   410
    "return an Integer useful as a hash key for the receiver."
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   411
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   412
    ^ 17467     "/ any arbitrary value
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   413
! !
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   414
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   415
!Infinity::NegativeInfinity methodsFor:'printing'!
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   416
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   417
printOn: aStream
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   418
    aStream nextPutAll:'-INF'
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   419
! !
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   420
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   421
!Infinity::NegativeInfinity methodsFor:'testing'!
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   422
24955
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   423
negative
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   424
    ^ true
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   425
!
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   426
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   427
positive
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   428
    "return true, if the receiver is greater or equal to zero (not negative)"
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   429
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   430
    ^ false
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   431
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   432
    "Created: / 21-06-2017 / 14:02:18 / cg"
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   433
    "Modified (comment): / 28-05-2019 / 05:55:45 / Claus Gittinger"
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   434
!
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   435
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   436
sign
7471
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   437
    "return the sign of the receiver (1)"
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   438
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   439
    ^ -1
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   440
! !
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   441
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   442
!Infinity::PositiveInfinity methodsFor:'arithmetic'!
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   443
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   444
negated
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   445
    ^ InfNeg
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   446
! !
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   447
16037
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   448
!Infinity::PositiveInfinity methodsFor:'comparing'!
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   449
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   450
hash
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   451
    "return an Integer useful as a hash key for the receiver."
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   452
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   453
    ^ 17471     "/ any arbitrary value
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   454
! !
7636de526b0d class: Infinity
Claus Gittinger <cg@exept.de>
parents: 15404
diff changeset
   455
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   456
!Infinity::PositiveInfinity methodsFor:'printing'!
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   457
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   458
printOn: aStream
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   459
    aStream nextPutAll:'INF'
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   460
! !
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   461
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   462
!Infinity::PositiveInfinity methodsFor:'testing'!
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   463
24955
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   464
negative
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   465
    ^ false
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   466
!
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   467
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   468
positive
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   469
    "return true, if the receiver is greater or equal to zero (not negative)"
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   470
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   471
    ^ true
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   472
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   473
    "Created: / 21-06-2017 / 14:02:28 / cg"
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   474
    "Modified (comment): / 28-05-2019 / 05:55:48 / Claus Gittinger"
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   475
!
383d5baf43e1 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24708
diff changeset
   476
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   477
sign
7471
c5d4bd612d9f comments
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   478
    "return the sign of the receiver (-1)"
7469
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   479
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   480
    ^ 1
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   481
! !
86006c0e12d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7452
diff changeset
   482
7443
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   483
!Infinity class methodsFor:'documentation'!
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   484
3407302dc4d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6501
diff changeset
   485
version
18856
8ad83639df20 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16037
diff changeset
   486
    ^ '$Header$'
12246
e5cc18fff88b changed: #=
Claus Gittinger <cg@exept.de>
parents: 7548
diff changeset
   487
!
e5cc18fff88b changed: #=
Claus Gittinger <cg@exept.de>
parents: 7548
diff changeset
   488
e5cc18fff88b changed: #=
Claus Gittinger <cg@exept.de>
parents: 7548
diff changeset
   489
version_CVS
18856
8ad83639df20 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16037
diff changeset
   490
    ^ '$Header$'
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   491
! !
f014922e3b71 Initial revision
claus
parents:
diff changeset
   492
15404
c08c1ddf8df7 class: Infinity
Stefan Vogel <sv@exept.de>
parents: 12246
diff changeset
   493
265
f014922e3b71 Initial revision
claus
parents:
diff changeset
   494
Infinity initialize!