7436
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
21887
|
12 |
"{ Package: 'stx:libbasic' }"
|
7436
|
13 |
|
21887
|
14 |
"{ NameSpace: Smalltalk }"
|
7436
|
15 |
|
|
16 |
MetaNumber subclass:#NotANumber
|
|
17 |
instanceVariableNames:''
|
|
18 |
classVariableNames:'NaN'
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Magnitude-Numbers'
|
|
21 |
!
|
|
22 |
|
|
23 |
!NotANumber class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
!
|
|
38 |
|
|
39 |
documentation
|
|
40 |
"
|
21887
|
41 |
Represents the NaN metaNumber for non-float classes.
|
7436
|
42 |
|
|
43 |
[author:]
|
|
44 |
Claus Gittinger
|
|
45 |
|
|
46 |
[see also:]
|
21887
|
47 |
Number Infinity
|
|
48 |
Float ShortFloat LongFloat QDouble Fraction FixedPoint Integer Complex
|
7436
|
49 |
FloatArray DoubleArray
|
|
50 |
"
|
|
51 |
! !
|
|
52 |
|
|
53 |
!NotANumber class methodsFor:'instance creation'!
|
|
54 |
|
21892
|
55 |
NaN
|
|
56 |
^ NaN
|
|
57 |
|
|
58 |
"Created: / 21-06-2017 / 20:36:00 / cg"
|
|
59 |
!
|
|
60 |
|
7436
|
61 |
new
|
|
62 |
^ NaN
|
|
63 |
! !
|
|
64 |
|
|
65 |
!NotANumber class methodsFor:'class initialization'!
|
|
66 |
|
|
67 |
initialize
|
|
68 |
NaN := self basicNew
|
|
69 |
|
|
70 |
"
|
|
71 |
self initialize
|
|
72 |
"
|
|
73 |
! !
|
|
74 |
|
|
75 |
!NotANumber methodsFor:'arithmetic'!
|
|
76 |
|
|
77 |
* aNumber
|
|
78 |
"Multiply the receiver and the argument and answer with the result."
|
|
79 |
|
|
80 |
^ self
|
|
81 |
!
|
|
82 |
|
|
83 |
+ aNumber
|
|
84 |
"Add the receiver and the argument and answer with the result."
|
|
85 |
|
|
86 |
^ self
|
|
87 |
!
|
|
88 |
|
|
89 |
- aNumber
|
|
90 |
"Subtract the argument from the receiver and answer with the result."
|
|
91 |
|
|
92 |
^ self
|
|
93 |
!
|
|
94 |
|
|
95 |
/ aNumber
|
|
96 |
"Divide the receiver by the argument and answer with the result."
|
|
97 |
|
|
98 |
^ self
|
|
99 |
! !
|
|
100 |
|
|
101 |
!NotANumber methodsFor:'comparing'!
|
|
102 |
|
|
103 |
= something
|
7471
|
104 |
"return true, if the argument represents the same numeric value
|
|
105 |
as the receiver, false otherwise."
|
|
106 |
|
7436
|
107 |
something respondsToArithmetic ifTrue:[ ^ something isNaN ].
|
|
108 |
^ false.
|
|
109 |
! !
|
|
110 |
|
|
111 |
!NotANumber methodsFor:'double dispatching'!
|
|
112 |
|
|
113 |
differenceFromSomeNumber:aNumber
|
|
114 |
"sent from aNumber-self, if aNumber does not know how to handle this"
|
|
115 |
|
|
116 |
^ self
|
|
117 |
!
|
|
118 |
|
|
119 |
lessFromSomeNumber:aNumber
|
|
120 |
"sent from aNumber < self, if aNumber does not know how to handle this"
|
|
121 |
|
|
122 |
^ Number
|
|
123 |
raise: #undefinedResultSignal
|
|
124 |
receiver: self
|
|
125 |
selector: #lessFromSomeNumber:
|
|
126 |
errorString: 'Cannot compare against NaN'
|
|
127 |
!
|
|
128 |
|
|
129 |
productFromSomeNumber:aNumber
|
|
130 |
"sent from aNumber*self, if aNumber does not know how to handle this"
|
|
131 |
|
|
132 |
^ self
|
|
133 |
!
|
|
134 |
|
|
135 |
quotientFromSomeNumber:aNumber
|
|
136 |
"Return the quotient of the argument, aNumber and the receiver.
|
|
137 |
Sent when aNumber does not know how to divide by the receiver."
|
|
138 |
|
|
139 |
^ self
|
|
140 |
!
|
|
141 |
|
|
142 |
sumFromSomeNumber:aNumber
|
|
143 |
"sent from aNumber+self, if aNumber does not know how to handle this"
|
|
144 |
|
|
145 |
^ self
|
|
146 |
! !
|
|
147 |
|
|
148 |
!NotANumber methodsFor:'printing'!
|
|
149 |
|
|
150 |
printOn:aStream
|
|
151 |
aStream nextPutAll:'NAN'
|
|
152 |
! !
|
|
153 |
|
|
154 |
!NotANumber methodsFor:'testing'!
|
|
155 |
|
|
156 |
isFinite
|
|
157 |
^ false
|
|
158 |
!
|
|
159 |
|
|
160 |
isNaN
|
|
161 |
^ true
|
|
162 |
! !
|
|
163 |
|
|
164 |
!NotANumber class methodsFor:'documentation'!
|
|
165 |
|
|
166 |
version
|
21887
|
167 |
^ '$Header$'
|
21892
|
168 |
!
|
|
169 |
|
|
170 |
version_CVS
|
|
171 |
^ '$Header$'
|
7436
|
172 |
! !
|
|
173 |
|
21887
|
174 |
|
7436
|
175 |
NotANumber initialize!
|