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