author | Jan Vrany <jan.vrany@labware.com> |
Mon, 29 Nov 2021 23:00:04 +0000 | |
branch | jv |
changeset 25437 | 622824e701ea |
parent 23547 | c69c97cec351 |
permissions | -rw-r--r-- |
10825 | 1 |
" |
2 |
COPYRIGHT (c) 2007 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 |
"{ Package: 'stx:libbasic' }" |
|
13 |
||
18832 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
10825 | 16 |
Number subclass:#MeasurementValue |
17 |
instanceVariableNames:'value minValue maxValue' |
|
11465 | 18 |
classVariableNames:'MeasurementValueZero' |
10825 | 19 |
poolDictionaries:'' |
20 |
category:'Magnitude-Numbers' |
|
21 |
! |
|
22 |
||
23 |
!MeasurementValue class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2007 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 |
" |
|
41 |
A MeasurementValue is a numeric value with an error, such as returned |
|
42 |
by measurement devices (Volt-Meter). For example, if a measurement-device has |
|
43 |
an error of 10%, a measured value of 20 could be any value between 18 and 22. |
|
44 |
||
45 |
Arithmetic operations keep track of the error; if any operand is a MeasurementValue, |
|
46 |
the operation returns a MeasurementValue as result. |
|
47 |
||
48 |
This class is possibly unfinished and needs more arithmetic methods. |
|
49 |
For now, the stuff found here represents our needs and more might be added in the future. |
|
50 |
||
11456 | 51 |
Also notice, that instances do not keep the error as a fraction, but instead a min. and maxValue. |
11606 | 52 |
That means, that we can handle the case where the error is different in |
11456 | 53 |
the positive and negative directions. |
11607 | 54 |
I am not sure if this is more flexibility than needed in the long run. |
11456 | 55 |
|
10825 | 56 |
[author:] |
57 |
Claus Gittinger |
|
58 |
||
59 |
[see also:] |
|
60 |
Number |
|
61 |
Float ShortFloat Fraction FixedPoint Integer Complex |
|
62 |
FloatArray DoubleArray |
|
63 |
" |
|
64 |
! |
|
65 |
||
66 |
examples |
|
67 |
" |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
68 |
Notice, how the errors accumulate... |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
69 |
[exBegin] |
10825 | 70 |
|voltage current power| |
71 |
||
72 |
voltage := MeasurementValue value:10 error:0.05. |
|
73 |
current := MeasurementValue value:2 error:0.1. |
|
74 |
power := voltage * current. |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
75 |
power. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
76 |
power minValue. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
77 |
power maxValue. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
78 |
[exEnd] |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
79 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
80 |
[exBegin] |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
81 |
|voltage current power| |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
82 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
83 |
voltage := MeasurementValue value:10 error:0.05. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
84 |
current := 2. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
85 |
power := voltage * current. |
10825 | 86 |
power |
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
87 |
[exEnd] |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
88 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
89 |
[exBegin] |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
90 |
|voltage doubleVoltage| |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
91 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
92 |
voltage := MeasurementValue value:10 error:0.1. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
93 |
doubleVoltage := 2 * voltage. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
94 |
doubleVoltage |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
95 |
[exEnd] |
10825 | 96 |
" |
97 |
! ! |
|
98 |
||
99 |
!MeasurementValue class methodsFor:'instance creation'! |
|
100 |
||
14445 | 101 |
value:valueArg error:errorArg |
10825 | 102 |
"return a new measurementValue with a given value and an error (fraction)" |
103 |
||
14445 | 104 |
^ self new value:valueArg error:errorArg |
10825 | 105 |
|
14445 | 106 |
"10 with an error of 20%: |
107 |
||
10825 | 108 |
MeasurementValue value:10 error:0.2 |
109 |
" |
|
110 |
! |
|
111 |
||
14445 | 112 |
value:valueArg minValue:minArg maxValue:maxArg |
10825 | 113 |
"return a new measurementValue with a given value and an error given as min-max values. |
114 |
Use this, if the error is not the same in both directions" |
|
115 |
||
14445 | 116 |
^ self new value:valueArg minValue:minArg maxValue:maxArg |
10825 | 117 |
|
14445 | 118 |
"an order of magnitude error: |
119 |
||
10825 | 120 |
MeasurementValue value:5 minValue:1 maxValue:10 |
121 |
" |
|
122 |
! ! |
|
123 |
||
11465 | 124 |
!MeasurementValue class methodsFor:'constants'! |
125 |
||
11466 | 126 |
unity |
127 |
"return the neutral element for multiplication" |
|
128 |
||
129 |
^ 1 |
|
130 |
||
131 |
" |
|
132 |
self unity |
|
133 |
" |
|
134 |
! |
|
135 |
||
11465 | 136 |
zero |
137 |
"return the neutral element for addition (0 +/- 0)" |
|
138 |
||
139 |
MeasurementValueZero isNil ifTrue:[ |
|
140 |
MeasurementValueZero := self value:0 minValue:0 maxValue:0 |
|
141 |
]. |
|
142 |
^ MeasurementValueZero |
|
143 |
||
144 |
" |
|
145 |
self zero |
|
146 |
" |
|
147 |
! ! |
|
148 |
||
10825 | 149 |
!MeasurementValue methodsFor:'accessing'! |
150 |
||
151 |
maxValue |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
152 |
"the maximum possible value, considerung what has been measured and what the measurement error is" |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
153 |
|
10825 | 154 |
^ maxValue |
155 |
! |
|
156 |
||
157 |
minValue |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
158 |
"the minimum possible value, considerung what has been measured and what the measurement error is" |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
159 |
|
10825 | 160 |
^ minValue |
161 |
! |
|
162 |
||
163 |
value |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
164 |
"the measured value" |
10825 | 165 |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
166 |
^ value |
10825 | 167 |
! ! |
168 |
||
169 |
!MeasurementValue methodsFor:'arithmetic'! |
|
170 |
||
171 |
* aNumber |
|
11726 | 172 |
"return the product of the receiver and the argument. |
173 |
Care for the error to propagate into the result." |
|
174 |
||
10825 | 175 |
^ MeasurementValue new |
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
176 |
value:(value * aNumber value) |
14445 | 177 |
minValue:((minValue * aNumber minValue) min:(maxValue * aNumber minValue)) |
178 |
maxValue:((maxValue * aNumber maxValue) max:(minValue * aNumber maxValue)) |
|
179 |
||
180 |
" |
|
181 |
(MeasurementValue value:-10 error:0.2) * (MeasurementValue value:-10 error:0.2) |
|
182 |
(MeasurementValue value:-10 error:0.2) * 2 |
|
183 |
" |
|
10825 | 184 |
! |
185 |
||
186 |
+ aNumber |
|
11726 | 187 |
"return the sum of the receiver and the argument. |
188 |
Care for the error to propagate into the result." |
|
189 |
||
10825 | 190 |
^ MeasurementValue new |
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
191 |
value:(value + aNumber value) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
192 |
minValue:(minValue + aNumber minValue) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
193 |
maxValue:(maxValue + aNumber maxValue) |
14445 | 194 |
|
195 |
" |
|
196 |
(MeasurementValue value:-10 error:0.2) + (MeasurementValue value:-10 error:0.2) |
|
197 |
(MeasurementValue value:-10 error:0.2) + 2 |
|
198 |
" |
|
10825 | 199 |
! |
200 |
||
201 |
- aNumber |
|
11726 | 202 |
"return the difference of the receiver and the argument. |
203 |
Care for the error to propagate into the result." |
|
204 |
||
10825 | 205 |
^ MeasurementValue new |
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
206 |
value:(value - aNumber value) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
207 |
minValue:(minValue - aNumber maxValue) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
208 |
maxValue:(maxValue - aNumber minValue) |
14445 | 209 |
|
210 |
" |
|
211 |
(MeasurementValue value:-10 error:0.2) - (MeasurementValue value:-10 error:0.2) |
|
212 |
(MeasurementValue value:-10 error:0.2) - 10 |
|
213 |
(MeasurementValue value:10 error:0.2) - 10 |
|
214 |
" |
|
10825 | 215 |
! |
216 |
||
217 |
/ aNumber |
|
11726 | 218 |
"return the quotient of the receiver and the argument. |
219 |
Care for the error to propagate into the result." |
|
220 |
||
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
221 |
^ MeasurementValue new |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
222 |
value:(value / aNumber value) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
223 |
minValue:(minValue / aNumber maxValue) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
224 |
maxValue:(maxValue / aNumber minValue) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
225 |
! ! |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
226 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
227 |
!MeasurementValue methodsFor:'coercing & converting'! |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
228 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
229 |
+/- error |
14008 | 230 |
"return a MeasurementValue with a given error." |
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
231 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
232 |
"/ what should I do here - take the new error, |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
233 |
"/ or multiply them ???? |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
234 |
self error. |
10825 | 235 |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
236 |
minValue := value - error. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
237 |
maxValue := value + error. |
14008 | 238 |
|
239 |
"Modified (comment): / 14-02-2012 / 14:17:39 / cg" |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
240 |
! |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
241 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
242 |
coerce:aNumber |
18832 | 243 |
"convert the argument aNumber into an instance of the receiver's class and return it." |
11717 | 244 |
|
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
245 |
^ MeasurementValue value:aNumber minValue:aNumber maxValue:aNumber |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
246 |
! |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
247 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
248 |
generality |
11717 | 249 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
250 |
||
18832 | 251 |
"/ adding 1 to the value's generality has the subtle side effect of enforcing |
11717 | 252 |
"/ a call to coerce: for mixed type operations (i.e. Int * MeasurementValue). |
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
253 |
"/ try it. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
254 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
255 |
^ value generality + 1 |
10825 | 256 |
! ! |
257 |
||
258 |
!MeasurementValue methodsFor:'comparing'! |
|
259 |
||
260 |
< aNumber |
|
11726 | 261 |
"return true, if the argument is greater than the receiver. |
262 |
Care for the error - i.e. compare against my maximum-value" |
|
263 |
||
10825 | 264 |
^ maxValue < aNumber |
265 |
! |
|
266 |
||
11465 | 267 |
= aNumber |
11726 | 268 |
"hard to tell, what we want here... |
269 |
How about: aNumber between:minValue and:maxValue ???" |
|
11465 | 270 |
|
271 |
^ value = aNumber value |
|
272 |
and:[ minValue = aNumber minValue |
|
273 |
and:[ maxValue = aNumber maxValue ]] |
|
274 |
! |
|
275 |
||
16274 | 276 |
hash |
277 |
^ value hash |
|
278 |
! |
|
279 |
||
10825 | 280 |
lessFromFloat:aFloat |
281 |
"aFloat < self ?" |
|
282 |
||
283 |
^ aFloat < minValue |
|
284 |
! |
|
285 |
||
286 |
lessFromInteger:anInteger |
|
287 |
"anInteger < self ?" |
|
288 |
||
289 |
^ anInteger < minValue |
|
290 |
! ! |
|
291 |
||
292 |
!MeasurementValue methodsFor:'printing & storing'! |
|
293 |
||
294 |
printOn:aStream |
|
11459 | 295 |
aStream nextPutAll:'('. |
296 |
(maxValue-value) = (value-minValue) ifTrue:[ |
|
297 |
value storeOn:aStream. |
|
298 |
aStream nextPutAll:' +/- '. |
|
14445 | 299 |
(maxValue-value) abs storeOn:aStream |
11459 | 300 |
] ifFalse:[ |
301 |
aStream nextPutAll:'MeasurementValue value:'. |
|
302 |
value storeOn:aStream. |
|
303 |
aStream nextPutAll:' minValue:'. |
|
304 |
minValue storeOn:aStream. |
|
305 |
aStream nextPutAll:' maxValue:'. |
|
306 |
maxValue storeOn:aStream. |
|
307 |
]. |
|
10825 | 308 |
')' printOn:aStream. |
11459 | 309 |
|
310 |
" |
|
311 |
(5 +/- 1) storeString |
|
312 |
(MeasurementValue value:5 minValue:3 maxValue:8) storeString |
|
313 |
" |
|
10825 | 314 |
! ! |
315 |
||
11457
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
316 |
!MeasurementValue methodsFor:'private accessing'! |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
317 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
318 |
value:valueArg error:errorFraction |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
319 |
self |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
320 |
value:valueArg |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
321 |
minValue:(valueArg * (1-errorFraction)) |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
322 |
maxValue:(valueArg * (1+errorFraction)). |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
323 |
! |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
324 |
|
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
325 |
value:valueArg minValue:minValueArg maxValue:maxValueArg |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
326 |
value := valueArg. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
327 |
minValue := minValueArg. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
328 |
maxValue := maxValueArg. |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
329 |
! ! |
5ff638783ee0
double dispatch (actually coercing) support
Claus Gittinger <cg@exept.de>
parents:
11456
diff
changeset
|
330 |
|
14445 | 331 |
!MeasurementValue methodsFor:'queries'! |
332 |
||
333 |
error |
|
334 |
"the relative error. |
|
335 |
If the error is different in the min/max direction, the larger error is returned here" |
|
336 |
||
337 |
^ self errorHigh max:(self errorLow) |
|
338 |
||
339 |
" |
|
340 |
(MeasurementValue value:10 error:0.2) errorLow |
|
341 |
(MeasurementValue value:10 error:0.2) errorHigh |
|
342 |
(MeasurementValue value:10 error:0.2) error |
|
343 |
" |
|
344 |
! |
|
345 |
||
346 |
errorHigh |
|
347 |
"the relative error on the max side" |
|
348 |
||
349 |
^ (value - maxValue) abs / value |
|
350 |
||
351 |
" |
|
352 |
(MeasurementValue value:10 error:0.2) errorLow |
|
353 |
(MeasurementValue value:10 error:0.2) errorHigh |
|
354 |
(MeasurementValue value:10 error:0.2) error |
|
355 |
(MeasurementValue value:20 error:0.2) errorLow |
|
356 |
(MeasurementValue value:20 minValue:1 maxValue:100) errorLow |
|
357 |
(MeasurementValue value:20 minValue:1 maxValue:100) errorHigh |
|
358 |
(MeasurementValue value:20 minValue:1 maxValue:100) error |
|
359 |
" |
|
360 |
! |
|
361 |
||
362 |
errorLow |
|
363 |
"the relative error on the min side" |
|
364 |
||
365 |
^ (value - minValue) abs / value |
|
366 |
||
367 |
" |
|
368 |
(MeasurementValue value:10 error:0.2) errorLow |
|
369 |
(MeasurementValue value:10 error:0.2) errorHigh |
|
370 |
(MeasurementValue value:10 error:0.2) error |
|
371 |
(MeasurementValue value:20 error:0.2) errorLow |
|
372 |
(MeasurementValue value:20 minValue:1 maxValue:100) errorLow |
|
373 |
(MeasurementValue value:20 minValue:1 maxValue:100) errorHigh |
|
374 |
(MeasurementValue value:20 minValue:1 maxValue:100) error |
|
375 |
" |
|
376 |
! ! |
|
377 |
||
10825 | 378 |
!MeasurementValue methodsFor:'testing'! |
379 |
||
380 |
between:min and:max |
|
381 |
minValue < min ifTrue:[^ false]. |
|
382 |
maxValue > max ifTrue:[^ false]. |
|
383 |
^ true |
|
384 |
! ! |
|
385 |
||
386 |
!MeasurementValue class methodsFor:'documentation'! |
|
387 |
||
388 |
version |
|
18832 | 389 |
^ '$Header$' |
10825 | 390 |
! ! |
16274 | 391 |