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