author | Claus Gittinger <cg@exept.de> |
Tue, 05 Nov 1996 19:36:39 +0100 | |
changeset 1892 | d3564145c15c |
parent 1879 | 26df273349c4 |
child 1893 | c66af5c46272 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
175 | 3 |
All Rights Reserved |
1 | 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 |
||
54 | 13 |
LimitedPrecisionReal variableByteSubclass:#Float |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
14 |
instanceVariableNames:'' |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
15 |
classVariableNames:'' |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
16 |
poolDictionaries:'' |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
17 |
category:'Magnitude-Numbers' |
1 | 18 |
! |
19 |
||
701 | 20 |
!Float primitiveDefinitions! |
21 |
%{ |
|
22 |
#include <errno.h> |
|
23 |
||
24 |
/* |
|
25 |
* on some systems errno is a macro ... check for it here |
|
26 |
*/ |
|
27 |
#ifndef errno |
|
28 |
extern errno; |
|
29 |
#endif |
|
30 |
||
31 |
%} |
|
32 |
! ! |
|
33 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
34 |
!Float class methodsFor:'documentation'! |
68 | 35 |
|
88 | 36 |
copyright |
37 |
" |
|
38 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
175 | 39 |
All Rights Reserved |
88 | 40 |
|
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
" |
|
48 |
! |
|
49 |
||
68 | 50 |
documentation |
51 |
" |
|
52 |
Floats represent rational numbers with limited precision. In ST/X, Float uses |
|
53 |
the underlying C-compilers double implementation, therefore instances of Float |
|
54 |
are usually represented by the 8-byte IEE double precision float format. |
|
55 |
(but there is no guaranty). |
|
1 | 56 |
|
68 | 57 |
Notice, that Floats are defined as Byte-array to prevent the garbage collector |
58 |
from going into the value ... otherwise I needed a special case in many places. |
|
59 |
||
60 |
Also notice, that ST/X Floats are what Doubles are in ST-80 - this may change |
|
61 |
in one of the next versions (at least on machines, which provide different float |
|
62 |
and double types in their C-compiler. |
|
63 |
||
64 |
WARNING: |
|
65 |
The layout of float instances is known by the runtime system and the compiler; |
|
66 |
you may not add instance variables here. |
|
369 | 67 |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
68 |
Also, subclassing is complicated by the fact, that the VM creates floats as results |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
69 |
of arithmetic operations (even if the operands are subclass-instances). |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
70 |
(It does the float-check by probing a bit in the classes flag instVar). |
85 | 71 |
|
1892 | 72 |
Mixed mode arithmetic: |
73 |
float op float -> float |
|
74 |
float op fix -> float |
|
75 |
float op integer -> float |
|
76 |
float op float -> float |
|
77 |
||
1295 | 78 |
[Class Variables:] |
85 | 79 |
|
1295 | 80 |
[see also:] |
81 |
Number |
|
1556 | 82 |
ShortFloat Fraction Integer |
1295 | 83 |
FloatArray DoubleArray |
84 |
||
85 |
[author:] |
|
86 |
Claus Gittinger |
|
68 | 87 |
" |
88 |
! ! |
|
1 | 89 |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
90 |
!Float class methodsFor:'instance creation'! |
1 | 91 |
|
92 |
basicNew |
|
93 |
"return a new float - here we return 0.0 |
|
94 |
- floats are usually NOT created this way ... |
|
95 |
Its implemented here to allow things like binary store & load |
|
96 |
of floats. (but even this support will go away eventually, its not |
|
97 |
a good idea to store the bits of a float - the reader might have a |
|
13 | 98 |
totally different representation - so floats will eventually be |
99 |
binary stored in a device independent format." |
|
1 | 100 |
|
101 |
%{ /* NOCONTEXT */ |
|
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
102 |
OBJ newFloat; |
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
103 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
104 |
__qMKFLOAT(newFloat, 0.0); |
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
105 |
RETURN (newFloat); |
1 | 106 |
%} |
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
107 |
|
1 | 108 |
! ! |
109 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
110 |
!Float class methodsFor:'binary storage'! |
701 | 111 |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
112 |
binaryDefinitionFrom:aStream manager: manager |
701 | 113 |
|f| |
114 |
||
115 |
f := self basicNew. |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
116 |
self readBinaryIEEEDoubleFrom:aStream into:f. |
701 | 117 |
^ f |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
118 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
119 |
"Modified: 16.4.1996 / 21:23:38 / cg" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
120 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
121 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
122 |
readBinaryIEEEDoubleFrom:aStream |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
123 |
"read a float from the binary stream, aStream, |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
124 |
interpreting the next bytes as an IEEE formatted 8-byte float" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
125 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
126 |
|f| |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
127 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
128 |
f := self basicNew. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
129 |
self readBinaryIEEEDoubleFrom:aStream into:f. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
130 |
^ f |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
131 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
132 |
"Created: 16.4.1996 / 20:59:59 / cg" |
701 | 133 |
! |
134 |
||
135 |
readBinaryIEEEDoubleFrom:aStream into:aFloat |
|
136 |
"read the receivers value from the binary stream, aStream, |
|
137 |
interpreting the next bytes as an IEEE formatted 8-byte float" |
|
138 |
||
139 |
" |
|
140 |
this implementation is wrong: does not work on non-IEEE machines |
|
141 |
(to date all machines where ST/X is running on use |
|
142 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
143 |
" |
|
144 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
145 |
"swap the bytes" |
|
146 |
8 to:1 by:-1 do:[:i | |
|
147 |
aFloat basicAt:i put:(aStream next) |
|
148 |
]. |
|
149 |
^ self |
|
150 |
]. |
|
151 |
1 to:8 do:[:i | |
|
152 |
aFloat basicAt:i put:aStream next |
|
153 |
] |
|
154 |
! |
|
155 |
||
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
156 |
readBinaryIEEESingleFrom:aStream |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
157 |
"read a float value from the binary stream, aStream, |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
158 |
interpreting the next bytes as an IEEE formatted 4-byte float" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
159 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
160 |
|f| |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
161 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
162 |
f := self basicNew. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
163 |
self readBinaryIEEESingleFrom:aStream into:f. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
164 |
^ f |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
165 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
166 |
"Created: 16.4.1996 / 21:00:35 / cg" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
167 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
168 |
|
701 | 169 |
readBinaryIEEESingleFrom:aStream into:aFloat |
170 |
"read a float value from the binary stream, aStream, |
|
171 |
interpreting the next bytes as an IEEE formatted 4-byte float" |
|
172 |
||
173 |
" |
|
174 |
this implementation is wrong: does not work on non-IEEE machines |
|
175 |
(to date all machines where ST/X is running on use |
|
176 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
177 |
" |
|
178 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
179 |
"swap the bytes" |
|
180 |
8 to:4 by:-1 do:[:i | |
|
181 |
aFloat basicAt:i put:(aStream next) |
|
182 |
]. |
|
183 |
^ self |
|
184 |
]. |
|
185 |
1 to:4 do:[:i | |
|
186 |
aFloat basicAt:i put:aStream next |
|
187 |
] |
|
188 |
! |
|
189 |
||
190 |
storeBinaryIEEEDouble:aFloat on:aStream |
|
191 |
"store aFloat as an IEEE formatted 8-byte float |
|
192 |
onto the binary stream, aStream" |
|
193 |
||
194 |
" |
|
195 |
this implementation is wrong: does not work on non-IEEE machines |
|
196 |
(to date all machines where ST/X is running on use |
|
197 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
198 |
" |
|
199 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
200 |
"swap the bytes" |
|
201 |
8 to:1 by:-1 do:[:i | |
|
202 |
aStream nextPut:(aFloat basicAt:i). |
|
203 |
]. |
|
204 |
^ self |
|
205 |
]. |
|
206 |
1 to:8 do:[:i | |
|
207 |
aStream nextPut:(aFloat basicAt:i). |
|
208 |
]. |
|
209 |
! |
|
210 |
||
211 |
storeBinaryIEEESingle:aFloat on:aStream |
|
212 |
"store aFloat as an IEEE formatted 4-byte float |
|
213 |
onto the binary stream, aStream" |
|
214 |
||
215 |
" |
|
216 |
this implementation is wrong: does not work on non-IEEE machines |
|
217 |
(to date all machines where ST/X is running on use |
|
218 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
219 |
" |
|
220 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
221 |
"swap the bytes" |
|
222 |
8 to:4 by:-1 do:[:i | |
|
223 |
aStream nextPut:(aFloat basicAt:i). |
|
224 |
]. |
|
225 |
^ self |
|
226 |
]. |
|
227 |
1 to:4 do:[:i | |
|
228 |
aStream nextPut:(aFloat basicAt:i). |
|
229 |
] |
|
230 |
! ! |
|
231 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
232 |
!Float class methodsFor:'constants'! |
1 | 233 |
|
701 | 234 |
pi |
1260 | 235 |
"return the constant pi as Float" |
1 | 236 |
|
701 | 237 |
^ 3.1415926535897932384626434 |
1260 | 238 |
|
239 |
"Modified: 23.4.1996 / 09:27:02 / cg" |
|
1 | 240 |
! |
241 |
||
242 |
unity |
|
1260 | 243 |
"return the neutral element for multiplication (1.0) as Float" |
1 | 244 |
|
245 |
^ 1.0 |
|
1260 | 246 |
|
247 |
"Modified: 23.4.1996 / 09:27:09 / cg" |
|
1 | 248 |
! |
249 |
||
701 | 250 |
zero |
1260 | 251 |
"return the neutral element for addition (0.0) as Float" |
1 | 252 |
|
701 | 253 |
^ 0.0 |
1260 | 254 |
|
255 |
"Modified: 23.4.1996 / 09:27:15 / cg" |
|
1 | 256 |
! ! |
257 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
258 |
!Float class methodsFor:'queries'! |
3 | 259 |
|
260 |
isBuiltInClass |
|
1264 | 261 |
"return true if this class is known by the run-time-system. |
262 |
Here, true is returned for myself, false for subclasses." |
|
3 | 263 |
|
264 |
^ self == Float |
|
1264 | 265 |
|
266 |
"Modified: 23.4.1996 / 15:59:04 / cg" |
|
3 | 267 |
! ! |
268 |
||
1 | 269 |
!Float methodsFor:'arithmetic'! |
270 |
||
701 | 271 |
* aNumber |
272 |
"return the product of the receiver and the argument, aNumber" |
|
273 |
||
274 |
%{ /* NOCONTEXT */ |
|
275 |
||
276 |
OBJ newFloat; |
|
277 |
double result; |
|
278 |
||
279 |
if (__isSmallInteger(aNumber)) { |
|
1133 | 280 |
result = __floatVal(self) * (double)(__intVal(aNumber)); |
701 | 281 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
282 |
__qMKFLOAT(newFloat, result); |
701 | 283 |
RETURN ( newFloat ); |
284 |
} |
|
285 |
if (__isFloatLike(aNumber)) { |
|
1133 | 286 |
result = __floatVal(self) * __floatVal(aNumber); |
701 | 287 |
goto retResult; |
288 |
} |
|
289 |
%} |
|
290 |
. |
|
291 |
^ aNumber productFromFloat:self |
|
292 |
! |
|
293 |
||
1 | 294 |
+ aNumber |
295 |
"return the sum of the receiver and the argument, aNumber" |
|
296 |
||
297 |
%{ /* NOCONTEXT */ |
|
13 | 298 |
|
1 | 299 |
OBJ newFloat; |
300 |
double result; |
|
301 |
||
250 | 302 |
if (__isSmallInteger(aNumber)) { |
1133 | 303 |
result = __floatVal(self) + (double)(__intVal(aNumber)); |
1 | 304 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
305 |
__qMKFLOAT(newFloat, result); |
175 | 306 |
RETURN ( newFloat ); |
1 | 307 |
} |
283 | 308 |
if (__isFloatLike(aNumber)) { |
1133 | 309 |
result = __floatVal(self) + __floatVal(aNumber); |
175 | 310 |
goto retResult; |
1 | 311 |
} |
312 |
%} |
|
313 |
. |
|
314 |
^ aNumber sumFromFloat:self |
|
315 |
! |
|
316 |
||
317 |
- aNumber |
|
318 |
"return the difference of the receiver and the argument, aNumber" |
|
319 |
||
320 |
%{ /* NOCONTEXT */ |
|
13 | 321 |
|
1 | 322 |
OBJ newFloat; |
323 |
double result; |
|
324 |
||
250 | 325 |
if (__isSmallInteger(aNumber)) { |
1133 | 326 |
result = __floatVal(self) - (double)(__intVal(aNumber)); |
1 | 327 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
328 |
__qMKFLOAT(newFloat, result); |
175 | 329 |
RETURN ( newFloat ); |
1 | 330 |
} |
283 | 331 |
if (__isFloatLike(aNumber)) { |
1133 | 332 |
result = __floatVal(self) - __floatVal(aNumber); |
175 | 333 |
goto retResult; |
1 | 334 |
} |
335 |
%} |
|
336 |
. |
|
337 |
^ aNumber differenceFromFloat:self |
|
338 |
! |
|
339 |
||
340 |
/ aNumber |
|
341 |
"return the quotient of the receiver and the argument, aNumber" |
|
342 |
||
343 |
%{ /* NOCONTEXT */ |
|
344 |
||
345 |
OBJ newFloat; |
|
346 |
double result, val; |
|
347 |
||
250 | 348 |
if (__isSmallInteger(aNumber)) { |
1133 | 349 |
if (aNumber != __MKSMALLINT(0)) { |
350 |
result = __floatVal(self) / ( (double)__intVal(aNumber)) ; |
|
1 | 351 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
352 |
__qMKFLOAT(newFloat, result); |
175 | 353 |
RETURN ( newFloat ); |
354 |
} |
|
1 | 355 |
} else { |
305 | 356 |
if (__isFloatLike(aNumber)) { |
1133 | 357 |
val = __floatVal(aNumber); |
175 | 358 |
if (val != 0.0) { |
1133 | 359 |
result = __floatVal(self) / val; |
175 | 360 |
goto retResult; |
361 |
} |
|
362 |
} |
|
1 | 363 |
} |
364 |
%} |
|
365 |
. |
|
366 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
|
142 | 367 |
" |
368 |
No, you shalt not divide by zero |
|
369 |
" |
|
175 | 370 |
^ DivisionByZeroSignal raise. |
1 | 371 |
]. |
372 |
^ aNumber quotientFromFloat:self |
|
373 |
! |
|
374 |
||
375 |
negated |
|
376 |
"return myself negated" |
|
377 |
||
378 |
%{ /* NOCONTEXT */ |
|
13 | 379 |
|
3 | 380 |
OBJ newFloat; |
1133 | 381 |
double rslt = - __floatVal(self); |
3 | 382 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
383 |
__qMKFLOAT(newFloat, rslt); |
3 | 384 |
RETURN ( newFloat ); |
1 | 385 |
%} |
386 |
! ! |
|
387 |
||
701 | 388 |
!Float methodsFor:'binary storage'! |
389 |
||
390 |
storeBinaryDefinitionOn:stream manager:manager |
|
1260 | 391 |
"store the receiver in a binary format on stream. |
392 |
This is an internal interface for binary storage mechanism." |
|
393 |
||
701 | 394 |
manager putIdOfClass:(self class) on:stream. |
395 |
Float storeBinaryIEEEDouble:self on:stream. |
|
1260 | 396 |
|
397 |
"Modified: 23.4.1996 / 09:29:48 / cg" |
|
701 | 398 |
! ! |
399 |
||
400 |
!Float methodsFor:'coercion and converting'! |
|
1 | 401 |
|
701 | 402 |
asFloat |
403 |
"return a float with same value - thats me" |
|
404 |
||
405 |
^ self |
|
406 |
! |
|
407 |
||
408 |
asInteger |
|
409 |
"return an integer with same value - might truncate" |
|
410 |
||
1 | 411 |
%{ /* NOCONTEXT */ |
1670 | 412 |
double dVal; |
13 | 413 |
|
1670 | 414 |
dVal = __floatVal(self); |
415 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
|
416 |
RETURN ( __MKSMALLINT( (INT)dVal) ); |
|
701 | 417 |
} |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
418 |
%}. |
701 | 419 |
^ super asInteger |
420 |
||
421 |
"12345.0 asInteger" |
|
422 |
"1e15 asInteger" |
|
1 | 423 |
! |
424 |
||
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
425 |
asShortFloat |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
426 |
"return a shortFloat with same value as receiver" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
427 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
428 |
%{ /* NOCONTEXT */ |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
429 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
430 |
OBJ dummy = @global(ShortFloat); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
431 |
OBJ newFloat; |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
432 |
float fVal = (float)__floatVal(self); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
433 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
434 |
__qMKSFLOAT(newFloat, fVal); |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
435 |
RETURN ( newFloat ); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
436 |
%} |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
437 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
438 |
|
701 | 439 |
coerce:aNumber |
440 |
"return aNumber converted into receivers type" |
|
1 | 441 |
|
701 | 442 |
^ aNumber asFloat |
443 |
! |
|
13 | 444 |
|
701 | 445 |
generality |
446 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
447 |
||
448 |
^ 80 |
|
1 | 449 |
! ! |
450 |
||
451 |
!Float methodsFor:'comparing'! |
|
452 |
||
453 |
< aNumber |
|
454 |
"return true, if the argument is greater" |
|
455 |
||
456 |
%{ /* NOCONTEXT */ |
|
13 | 457 |
|
250 | 458 |
if (__isSmallInteger(aNumber)) { |
1133 | 459 |
RETURN ( (__floatVal(self) < (double)(__intVal(aNumber))) ? true : false ); |
1 | 460 |
} |
283 | 461 |
if (__isFloatLike(aNumber)) { |
1133 | 462 |
RETURN ( (__floatVal(self) < __floatVal(aNumber)) ? true : false ); |
1 | 463 |
} |
464 |
%} |
|
465 |
. |
|
466 |
^ aNumber lessFromFloat:self |
|
467 |
! |
|
468 |
||
469 |
<= aNumber |
|
470 |
"return true, if the argument is greater or equal" |
|
471 |
||
472 |
%{ /* NOCONTEXT */ |
|
13 | 473 |
|
250 | 474 |
if (__isSmallInteger(aNumber)) { |
1133 | 475 |
RETURN ( (__floatVal(self) <= (double)(__intVal(aNumber))) ? true : false ); |
1 | 476 |
} |
283 | 477 |
if (__isFloatLike(aNumber)) { |
1133 | 478 |
RETURN ( (__floatVal(self) <= __floatVal(aNumber)) ? true : false ); |
1 | 479 |
} |
480 |
%} |
|
481 |
. |
|
482 |
^ self retry:#<= coercing:aNumber |
|
483 |
! |
|
484 |
||
485 |
= aNumber |
|
175 | 486 |
"return true, if the arguments value are equal by value" |
1 | 487 |
|
488 |
%{ /* NOCONTEXT */ |
|
13 | 489 |
|
250 | 490 |
if (__isSmallInteger(aNumber)) { |
1133 | 491 |
RETURN ( (__floatVal(self) == (double)(__intVal(aNumber))) ? true : false ); |
1 | 492 |
} |
283 | 493 |
if (__isFloatLike(aNumber)) { |
1133 | 494 |
RETURN ( (__floatVal(self) == __floatVal(aNumber)) ? true : false ); |
1 | 495 |
} |
496 |
%} |
|
497 |
. |
|
498 |
^ self retry:#= coercing:aNumber |
|
499 |
! |
|
500 |
||
701 | 501 |
> aNumber |
502 |
"return true, if the argument is less" |
|
1 | 503 |
|
504 |
%{ /* NOCONTEXT */ |
|
13 | 505 |
|
250 | 506 |
if (__isSmallInteger(aNumber)) { |
1133 | 507 |
RETURN ( (__floatVal(self) > (double)(__intVal(aNumber))) ? true : false ); |
1 | 508 |
} |
283 | 509 |
if (__isFloatLike(aNumber)) { |
1133 | 510 |
RETURN ( (__floatVal(self) > __floatVal(aNumber)) ? true : false ); |
1 | 511 |
} |
512 |
%} |
|
513 |
. |
|
701 | 514 |
^ self retry:#> coercing:aNumber |
515 |
! |
|
516 |
||
517 |
>= aNumber |
|
518 |
"return true, if the argument is less or equal" |
|
519 |
||
520 |
%{ /* NOCONTEXT */ |
|
521 |
||
522 |
if (__isSmallInteger(aNumber)) { |
|
1133 | 523 |
RETURN ( (__floatVal(self) >= (double)(__intVal(aNumber))) ? true : false ); |
701 | 524 |
} |
525 |
if (__isFloatLike(aNumber)) { |
|
1133 | 526 |
RETURN ( (__floatVal(self) >= __floatVal(aNumber)) ? true : false ); |
701 | 527 |
} |
528 |
%} |
|
529 |
. |
|
530 |
^ self retry:#>= coercing:aNumber |
|
92 | 531 |
! |
532 |
||
533 |
hash |
|
534 |
"return a number for hashing; redefined, since floats compare |
|
535 |
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same |
|
536 |
as 3 hash." |
|
537 |
||
305 | 538 |
|i| |
92 | 539 |
|
540 |
(self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[ |
|
175 | 541 |
i := self asInteger. |
542 |
self = i ifTrue:[ |
|
543 |
^ i hash |
|
544 |
]. |
|
92 | 545 |
]. |
546 |
||
547 |
" |
|
305 | 548 |
mhmh take some of my value-bits to hash on |
92 | 549 |
" |
305 | 550 |
^ (((self basicAt:8) bitAnd:16r3F) bitShift:24) + |
551 |
((self basicAt:7) bitShift:16) + |
|
552 |
((self basicAt:6) bitShift:8) + |
|
553 |
(self basicAt:5) |
|
92 | 554 |
|
555 |
" |
|
556 |
3 hash |
|
557 |
3.0 hash |
|
558 |
3.1 hash |
|
559 |
3.14159 hash |
|
560 |
31.4159 hash |
|
561 |
3.141591 hash |
|
562 |
1.234567890123456 hash |
|
563 |
1.234567890123457 hash |
|
564 |
Set withAll:#(3 3.0 99 99.0 3.1415) |
|
565 |
" |
|
1 | 566 |
! |
567 |
||
701 | 568 |
~= aNumber |
569 |
"return true, if the arguments value are not equal" |
|
1 | 570 |
|
571 |
%{ /* NOCONTEXT */ |
|
572 |
||
701 | 573 |
if (__isSmallInteger(aNumber)) { |
1133 | 574 |
RETURN ( (__floatVal(self) != (double)(__intVal(aNumber))) ? true : false ); |
701 | 575 |
} |
576 |
if (__isFloatLike(aNumber)) { |
|
1133 | 577 |
RETURN ( (__floatVal(self) != __floatVal(aNumber)) ? true : false ); |
1 | 578 |
} |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
579 |
%}. |
701 | 580 |
^ self retry:#~= coercing:aNumber |
1 | 581 |
! ! |
582 |
||
583 |
!Float methodsFor:'mathematical functions'! |
|
584 |
||
701 | 585 |
arcCos |
586 |
"return the arccosine of myself as radians" |
|
587 |
||
588 |
%{ /* NOCONTEXT */ |
|
589 |
||
590 |
double acos(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
591 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
592 |
OBJ newFloat; |
701 | 593 |
|
594 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
595 |
rslt = acos(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
596 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
597 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
598 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
599 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
600 |
%}. |
701 | 601 |
^ DomainErrorSignal raise |
602 |
! |
|
603 |
||
604 |
arcSin |
|
605 |
"return the arcsine of myself as radians" |
|
606 |
||
607 |
%{ /* NOCONTEXT */ |
|
608 |
||
609 |
double asin(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
610 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
611 |
OBJ newFloat; |
701 | 612 |
|
613 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
614 |
rslt = asin(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
615 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
616 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
617 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
618 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
619 |
%}. |
701 | 620 |
^ DomainErrorSignal raise |
621 |
! |
|
622 |
||
623 |
arcTan |
|
624 |
"return the arctangent of myself as radians" |
|
625 |
||
626 |
%{ /* NOCONTEXT */ |
|
627 |
||
628 |
double atan(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
629 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
630 |
OBJ newFloat; |
701 | 631 |
|
632 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
633 |
rslt = atan(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
634 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
635 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
636 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
637 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
638 |
%}. |
701 | 639 |
^ DomainErrorSignal raise |
640 |
! |
|
641 |
||
642 |
cos |
|
643 |
"return the cosine of myself interpreted as radians" |
|
644 |
||
645 |
%{ /* NOCONTEXT */ |
|
646 |
||
647 |
double cos(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
648 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
649 |
OBJ newFloat; |
701 | 650 |
|
651 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
652 |
rslt = cos(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
653 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
654 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
655 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
656 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
657 |
%}. |
701 | 658 |
^ DomainErrorSignal raise |
659 |
! |
|
660 |
||
661 |
exp |
|
662 |
"return e raised to the power of the receiver" |
|
663 |
||
664 |
%{ /* NOCONTEXT */ |
|
665 |
||
666 |
double exp(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
667 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
668 |
OBJ newFloat; |
701 | 669 |
|
670 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
671 |
rslt = exp(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
672 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
673 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
674 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
675 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
676 |
%}. |
701 | 677 |
^ DomainErrorSignal raise |
678 |
! |
|
679 |
||
1 | 680 |
ln |
681 |
"return the natural logarithm of myself" |
|
682 |
||
683 |
%{ /* NOCONTEXT */ |
|
684 |
||
685 |
double log(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
686 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
687 |
OBJ newFloat; |
1 | 688 |
|
689 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
690 |
rslt = log(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
691 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
692 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
693 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
694 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
695 |
%}. |
142 | 696 |
" |
697 |
an invalid value for logarithm |
|
698 |
" |
|
131 | 699 |
^ DomainErrorSignal raise |
1 | 700 |
! |
701 |
||
702 |
raisedTo:aNumber |
|
703 |
"return self raised to the power of aNumber" |
|
704 |
|n| |
|
705 |
||
706 |
n := aNumber asFloat. |
|
707 |
%{ |
|
708 |
double pow(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
709 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
710 |
OBJ newFloat; |
1 | 711 |
|
283 | 712 |
if (__isFloatLike(n)) { |
175 | 713 |
errno = 0; |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
714 |
rslt = pow(__floatVal(self), __floatVal(n)); |
175 | 715 |
errno = 0; /* XXXX */ |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
716 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
717 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
718 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
719 |
} |
1 | 720 |
} |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
721 |
%}. |
142 | 722 |
" |
723 |
an invalid argument (not convertable to float ?) |
|
724 |
" |
|
131 | 725 |
^ DomainErrorSignal raise |
1 | 726 |
! |
727 |
||
728 |
sin |
|
729 |
"return the sine of myself interpreted as radians" |
|
730 |
||
731 |
%{ /* NOCONTEXT */ |
|
732 |
||
733 |
double sin(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
734 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
735 |
OBJ newFloat; |
1 | 736 |
|
737 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
738 |
rslt = sin(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
739 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
740 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
741 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
742 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
743 |
%}. |
131 | 744 |
^ DomainErrorSignal raise |
1 | 745 |
! |
746 |
||
747 |
sqrt |
|
748 |
"return the square root of myself" |
|
749 |
||
750 |
%{ /* NOCONTEXT */ |
|
751 |
||
752 |
double sqrt(); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
753 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
754 |
OBJ newFloat; |
1 | 755 |
|
756 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
757 |
rslt = sqrt(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
758 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
759 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
760 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
761 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
762 |
%}. |
131 | 763 |
^ DomainErrorSignal raise |
701 | 764 |
! |
258 | 765 |
|
701 | 766 |
tan |
767 |
"return the tangent of myself interpreted as radians" |
|
258 | 768 |
|
769 |
%{ /* NOCONTEXT */ |
|
770 |
||
701 | 771 |
double tan(); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
772 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
773 |
OBJ newFloat; |
44 | 774 |
|
701 | 775 |
errno = 0; |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
776 |
rslt = tan(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
777 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
778 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
779 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
780 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
781 |
%}. |
701 | 782 |
^ DomainErrorSignal raise |
13 | 783 |
! ! |
784 |
||
92 | 785 |
!Float methodsFor:'printing & storing'! |
1 | 786 |
|
787 |
printString |
|
788 |
"return a printed representation of the receiver" |
|
789 |
||
790 |
%{ /* NOCONTEXT */ |
|
791 |
||
13 | 792 |
char buffer[64]; |
1 | 793 |
REGISTER char *cp; |
314 | 794 |
OBJ s; |
795 |
||
31 | 796 |
/* |
797 |
* actually only needed on sparc: since thisContext is |
|
798 |
* in a global register, which gets destroyed by printf, |
|
799 |
* manually save it here - very stupid ... |
|
800 |
*/ |
|
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
801 |
__BEGIN_PROTECT_REGISTERS__ |
1 | 802 |
|
803 |
#ifdef SYSV |
|
1133 | 804 |
sprintf(buffer, "%.6lg", __floatVal(self)); |
1 | 805 |
#else |
1133 | 806 |
sprintf(buffer, "%.6G", __floatVal(self)); |
1 | 807 |
#endif |
808 |
||
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
809 |
__END_PROTECT_REGISTERS__ |
1133 | 810 |
|
1 | 811 |
/* |
13 | 812 |
* kludge to make integral float f prints as "f.0" (not as "f" as printf does) |
1 | 813 |
* (i.e. look if string contains '.' or 'e' and append '.0' if not) |
814 |
*/ |
|
815 |
for (cp = buffer; *cp; cp++) { |
|
175 | 816 |
if ((*cp == '.') || (*cp == 'e')) break; |
1 | 817 |
} |
818 |
if (! *cp) { |
|
175 | 819 |
*cp++ = '.'; |
820 |
*cp++ = '0'; |
|
821 |
*cp = '\0'; |
|
1 | 822 |
} |
823 |
||
1133 | 824 |
s = __MKSTRING(buffer COMMA_SND); |
314 | 825 |
if (s != nil) { |
343 | 826 |
RETURN (s); |
314 | 827 |
} |
828 |
%}. |
|
829 |
" |
|
830 |
memory allocation (for the new string) failed. |
|
831 |
When we arrive here, there was no memory, even after a garbage collect. |
|
832 |
This means, that the VM wanted to get some more memory from the |
|
833 |
OS, which was not kind enough to give it. |
|
834 |
Bad luck - you should increase the swap space on your machine. |
|
835 |
" |
|
836 |
^ ObjectMemory allocationFailureSignal raise. |
|
837 |
||
1 | 838 |
"1.0 printString" |
839 |
"1.234 printString" |
|
840 |
"1e10 printString" |
|
841 |
"1.2e3 printString" |
|
842 |
"1.2e30 printString" |
|
843 |
! |
|
844 |
||
845 |
printfPrintString:formatString |
|
846 |
"non-portable: return a printed representation of the receiver |
|
847 |
as specified by formatString, which is defined by printf. |
|
31 | 848 |
If you use this, be aware, that specifying doubles differs on |
1 | 849 |
systems; on SYSV machines you have to give something like %lf, |
13 | 850 |
while on BSD systems the format string has to be %F. |
31 | 851 |
Also, the resulting string may not be longer than 255 bytes - |
54 | 852 |
since thats the (static) size of the buffer. |
853 |
This method is NONSTANDARD and may be removed without notice." |
|
1 | 854 |
|
13 | 855 |
%{ /* STACK: 400 */ |
1 | 856 |
char buffer[256]; |
314 | 857 |
OBJ s; |
1 | 858 |
|
54 | 859 |
if (__isString(formatString)) { |
175 | 860 |
/* |
861 |
* actually only needed on sparc: since thisContext is |
|
862 |
* in a global register, which gets destroyed by printf, |
|
863 |
* manually save it here - very stupid ... |
|
864 |
*/ |
|
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
865 |
__BEGIN_PROTECT_REGISTERS__ |
31 | 866 |
|
1133 | 867 |
sprintf(buffer, __stringVal(formatString), __floatVal(self)); |
369 | 868 |
|
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
869 |
__END_PROTECT_REGISTERS__ |
369 | 870 |
|
1133 | 871 |
s = __MKSTRING(buffer COMMA_SND); |
343 | 872 |
if (s != nil) { |
873 |
RETURN (s); |
|
874 |
} |
|
1 | 875 |
} |
314 | 876 |
%}. |
1 | 877 |
self primitiveFailed |
878 |
||
879 |
"Float pi printfPrintString:'%%lg -> %lg'" |
|
880 |
"Float pi printfPrintString:'%%lf -> %lf'" |
|
881 |
"Float pi printfPrintString:'%%7.5lg -> %7.5lg'" |
|
882 |
"Float pi printfPrintString:'%%7.5lf -> %7.5lf'" |
|
883 |
"Float pi printfPrintString:'%%G -> %G'" |
|
884 |
"Float pi printfPrintString:'%%F -> %F'" |
|
885 |
"Float pi printfPrintString:'%%7.5G -> %7.5G'" |
|
886 |
"Float pi printfPrintString:'%%7.5F -> %7.5F'" |
|
887 |
! ! |
|
701 | 888 |
|
889 |
!Float methodsFor:'private accessing'! |
|
890 |
||
891 |
basicAt:index |
|
892 |
"return an internal byte of the float. |
|
893 |
The value returned here depends on byte order, float representation etc. |
|
894 |
Therefore, this method should be used strictly private. |
|
895 |
||
896 |
Notice: |
|
897 |
the need to redefine this method here is due to the |
|
898 |
inability of many machines to store floats in non-double aligned memory. |
|
899 |
Therefore, on some machines, the first 4 bytes of a float are left unused, |
|
900 |
and the actual float is stored at index 5 .. 12. |
|
901 |
To hide this at one place, this method knows about that, and returns |
|
902 |
values as if this filler wasnt present." |
|
903 |
||
904 |
%{ /* NOCONTEXT */ |
|
905 |
||
906 |
register int indx; |
|
907 |
unsigned char *cp; |
|
908 |
||
909 |
/* |
|
910 |
* notice the missing test for self being a nonNilObject - |
|
911 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
912 |
* and SmallInteger |
|
913 |
*/ |
|
914 |
if (__isSmallInteger(index)) { |
|
1133 | 915 |
indx = __intVal(index) - 1; |
701 | 916 |
if ((indx >= 0) && (indx < sizeof(double))) { |
1133 | 917 |
cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue)); |
918 |
RETURN ( __MKSMALLINT(cp[indx] & 0xFF) ); |
|
701 | 919 |
} |
920 |
} |
|
921 |
%}. |
|
922 |
index isInteger ifFalse:[ |
|
923 |
^ self indexNotInteger |
|
924 |
]. |
|
925 |
^ self subscriptBoundsError:index |
|
926 |
! |
|
927 |
||
928 |
basicAt:index put:value |
|
929 |
"set an internal byte of the float. |
|
930 |
The value to be stored here depends on byte order, float representation etc. |
|
931 |
Therefore, this method should be used strictly private. |
|
932 |
||
933 |
Notice: |
|
934 |
the need to redefine this method here is due to the |
|
935 |
inability of many machines to store floats in non-double aligned memory. |
|
936 |
Therefore, on some machines, the first 4 bytes of a float are left unused, |
|
937 |
and the actual float is stored at index 5 .. 12. |
|
938 |
To hide this at one place, this method knows about that, and returns |
|
939 |
values as if this filler wasnt present." |
|
940 |
||
941 |
%{ /* NOCONTEXT */ |
|
942 |
register int indx, val; |
|
943 |
unsigned char *cp; |
|
944 |
||
945 |
/* |
|
946 |
* notice the missing test for self being a nonNilObject - |
|
947 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
948 |
* and SmallInteger |
|
949 |
*/ |
|
950 |
if (__bothSmallInteger(index, value)) { |
|
1133 | 951 |
val = __intVal(value); |
701 | 952 |
if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
1133 | 953 |
indx = __intVal(index) - 1; |
701 | 954 |
if ((indx >= 0) && (indx < sizeof(double))) { |
1133 | 955 |
cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue)); |
701 | 956 |
cp[indx] = val; |
957 |
RETURN ( value ); |
|
958 |
} |
|
959 |
} |
|
960 |
} |
|
961 |
%}. |
|
962 |
index isInteger ifFalse:[ |
|
963 |
^ self indexNotInteger |
|
964 |
]. |
|
965 |
value isInteger ifFalse:[ |
|
966 |
" |
|
967 |
the object to store should be an integer number |
|
968 |
" |
|
969 |
^ self elementNotInteger |
|
970 |
]. |
|
971 |
(value between:0 and:255) ifFalse:[ |
|
972 |
" |
|
973 |
the object to store must be a bytes value |
|
974 |
" |
|
975 |
^ self elementBoundsError |
|
976 |
]. |
|
977 |
^ self subscriptBoundsError:index |
|
978 |
! ! |
|
979 |
||
980 |
!Float methodsFor:'testing'! |
|
981 |
||
982 |
negative |
|
983 |
"return true if the receiver is less than zero" |
|
984 |
||
985 |
%{ /* NOCONTEXT */ |
|
986 |
||
1133 | 987 |
RETURN ( (__floatVal(self) < 0.0) ? true : false ); |
701 | 988 |
%} |
989 |
! |
|
990 |
||
991 |
positive |
|
992 |
"return true if the receiver is greater or equal to zero" |
|
993 |
||
994 |
%{ /* NOCONTEXT */ |
|
995 |
||
1133 | 996 |
RETURN ( (__floatVal(self) >= 0.0) ? true : false ); |
701 | 997 |
%} |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
998 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
999 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1000 |
strictlyPositive |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1001 |
"return true if the receiver is greater than zero" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1002 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1003 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1004 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1005 |
RETURN ( (__floatVal(self) > 0.0) ? true : false ); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1006 |
%} |
701 | 1007 |
! ! |
1008 |
||
1009 |
!Float methodsFor:'truncation and rounding'! |
|
1010 |
||
1011 |
ceiling |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1012 |
"return the smallest integer which is greater or equal to the receiver." |
701 | 1013 |
|
1014 |
|val| |
|
1015 |
||
1016 |
%{ |
|
1017 |
double ceil(); |
|
1018 |
double dVal; |
|
1019 |
||
1020 |
/* |
|
1021 |
* ST-80 (and X3J20) returns integer. |
|
1022 |
*/ |
|
1133 | 1023 |
dVal = ceil(__floatVal(self)); |
701 | 1024 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1025 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1026 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1027 |
val = __MKFLOAT(dVal); |
701 | 1028 |
%}. |
1029 |
^ val asInteger |
|
1030 |
! |
|
1031 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1032 |
ceilingAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1033 |
"return the smallest integer-valued float greater or equal to the receiver. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1034 |
This is much like #ceiling, but avoids a (possibly expensive) conversion |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1035 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1036 |
It may be useful, if the result is to be further used in another |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1037 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1038 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1039 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1040 |
double ceil(); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1041 |
double dVal; |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1042 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1043 |
/* |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1044 |
* ST-80 (and X3J20) returns integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1045 |
*/ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1046 |
dVal = ceil(__floatVal(self)); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1047 |
RETURN ( __MKFLOAT(dVal) ); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1048 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1049 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1050 |
|
701 | 1051 |
floor |
1052 |
"return the integer nearest the receiver towards negative infinity." |
|
1053 |
||
1054 |
|val| |
|
1055 |
||
1056 |
%{ |
|
1057 |
double floor(); |
|
1058 |
double dVal; |
|
1059 |
||
1060 |
/* |
|
1061 |
* ST-80 (and X3J20) returns integer. |
|
1062 |
*/ |
|
1133 | 1063 |
dVal = floor(__floatVal(self)); |
701 | 1064 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1065 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1066 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1067 |
val = __MKFLOAT(dVal); |
701 | 1068 |
%}. |
1069 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1070 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1071 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1072 |
0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1073 |
0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1074 |
-0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1075 |
-0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1076 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1077 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1078 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1079 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1080 |
floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1081 |
"return the integer nearest the receiver towards negative infinity |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1082 |
as a float. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1083 |
This is much like #floor, but avoids a (possibly expensive) conversion |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1084 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1085 |
It may be useful, if the result is to be further used in another |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1086 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1087 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1088 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1089 |
double floor(); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1090 |
double dVal; |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1091 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1092 |
dVal = floor(__floatVal(self)); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1093 |
RETURN ( __MKFLOAT(dVal) ); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1094 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1095 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1096 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1097 |
0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1098 |
0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1099 |
-0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1100 |
-0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1101 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1102 |
|
701 | 1103 |
! |
1104 |
||
1105 |
rounded |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1106 |
"return the receiver rounded to the nearest integer" |
701 | 1107 |
|
1108 |
|val| |
|
1109 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1110 |
%{ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1111 |
double floor(), ceil(); |
701 | 1112 |
double dVal; |
1113 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1114 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1115 |
if (dVal < 0.0) { |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1116 |
dVal = ceil(dVal - 0.5); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1117 |
} else { |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1118 |
dVal = floor(dVal + 0.5); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1119 |
} |
701 | 1120 |
/* |
1121 |
* ST-80 (and X3J20) returns integer. |
|
1122 |
*/ |
|
1123 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1124 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1125 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1126 |
val = __MKFLOAT(dVal); |
701 | 1127 |
%}. |
1128 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1129 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1130 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1131 |
0.4 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1132 |
0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1133 |
0.6 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1134 |
-0.4 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1135 |
-0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1136 |
-0.6 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1137 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1138 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1139 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1140 |
roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1141 |
"return the receiver rounded to the nearest integer as a float. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1142 |
This is much like #rounded, but avoids a (possibly expensive) conversion |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1143 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1144 |
It may be useful, if the result is to be further used in another |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1145 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1146 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1147 |
|val| |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1148 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1149 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1150 |
double floor(), ceil(); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1151 |
double dVal; |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1152 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1153 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1154 |
if (dVal < 0.0) { |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1155 |
dVal = ceil(dVal - 0.5); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1156 |
} else { |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1157 |
dVal = floor(dVal + 0.5); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1158 |
} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1159 |
RETURN ( __MKFLOAT(dVal) ); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1160 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1161 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1162 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1163 |
0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1164 |
-0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1165 |
0.5 roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1166 |
-0.5 roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1167 |
" |
701 | 1168 |
! |
1169 |
||
1170 |
truncated |
|
1171 |
"return the receiver truncated towards zero as an integer" |
|
1172 |
||
1173 |
|val| |
|
1174 |
||
1175 |
%{ |
|
1176 |
double floor(), ceil(); |
|
1177 |
double dVal; |
|
1178 |
||
1133 | 1179 |
dVal = __floatVal(self); |
701 | 1180 |
if (dVal < 0.0) { |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1181 |
dVal = ceil(dVal); |
701 | 1182 |
} else { |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1183 |
dVal = floor(dVal); |
701 | 1184 |
} |
1185 |
||
1186 |
/* |
|
1187 |
* ST-80 (and X3J20) returns integer. |
|
1188 |
*/ |
|
1189 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1190 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1191 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1192 |
val = __MKFLOAT(dVal); |
701 | 1193 |
%}. |
1194 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1195 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1196 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1197 |
0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1198 |
-0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1199 |
0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1200 |
-0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1201 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1202 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1203 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1204 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1205 |
truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1206 |
"return the receiver truncated towards zero as a float. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1207 |
This is much like #truncated, but avoids a (possibly expensive) conversion |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1208 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1209 |
It may be useful, if the result is to be further used in another |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1210 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1211 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1212 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1213 |
double floor(), ceil(); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1214 |
double dVal; |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1215 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1216 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1217 |
if (dVal < 0.0) { |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1218 |
dVal = ceil(dVal); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1219 |
} else { |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1220 |
dVal = floor(dVal); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1221 |
} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1222 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1223 |
RETURN ( __MKFLOAT(dVal) ); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1224 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1225 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1226 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1227 |
0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1228 |
-0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1229 |
0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1230 |
-0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1231 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1232 |
|
701 | 1233 |
! ! |
1234 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1235 |
!Float class methodsFor:'documentation'! |
701 | 1236 |
|
1237 |
version |
|
1892 | 1238 |
^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.45 1996-11-05 18:36:39 cg Exp $' |
701 | 1239 |
! ! |