author | Stefan Vogel <sv@exept.de> |
Mon, 26 Jul 1999 11:07:53 +0200 | |
changeset 4454 | 16acdd393dd0 |
parent 4387 | 8522ae8fa0b2 |
child 4590 | 3db3bf4615bd |
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:'' |
2358 | 15 |
classVariableNames:'DefaultPrintFormat' |
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 |
||
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
24 |
#ifndef __OPTIMIZE__ |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
25 |
# define __OPTIMIZE__ |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
26 |
#endif |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
27 |
#include <math.h> |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
28 |
|
701 | 29 |
/* |
30 |
* on some systems errno is a macro ... check for it here |
|
31 |
*/ |
|
32 |
#ifndef errno |
|
33 |
extern errno; |
|
34 |
#endif |
|
35 |
||
2394 | 36 |
#if defined (_AIX) |
37 |
# include <float.h> |
|
38 |
#endif |
|
2395 | 39 |
#if defined(IRIX) |
40 |
# include <nan.h> |
|
41 |
#endif |
|
2397 | 42 |
#if defined(LINUX) |
2396 | 43 |
# include <nan.h> |
44 |
#endif |
|
2399 | 45 |
#if defined(solaris) || defined(sunos) |
2398 | 46 |
# include <nan.h> |
47 |
#endif |
|
2394 | 48 |
|
3129 | 49 |
/* |
50 |
* sigh - some systems define that stuff; others dont. |
|
51 |
* (AIX even declares them as macros, so an external decl |
|
52 |
* will not work below ... |
|
53 |
*/ |
|
3240 | 54 |
#if !defined(_AIX) && !defined(NEXT3) |
3129 | 55 |
|
56 |
# ifdef acos |
|
57 |
double acos(); |
|
58 |
# endif |
|
59 |
# ifdef asin |
|
60 |
double asin(); |
|
61 |
# endif |
|
62 |
# ifndef atan |
|
63 |
double atan(); |
|
64 |
# endif |
|
65 |
# ifndef cos |
|
66 |
double cos(); |
|
67 |
# endif |
|
68 |
# ifndef sin |
|
69 |
double sin(); |
|
70 |
# endif |
|
71 |
# ifndef pow |
|
72 |
double pow(); |
|
73 |
# endif |
|
74 |
# ifndef log |
|
75 |
double log(); |
|
76 |
# endif |
|
77 |
# ifndef exp |
|
78 |
double exp(); |
|
79 |
# endif |
|
80 |
# ifndef sqrt |
|
81 |
double sqrt(); |
|
82 |
# endif |
|
83 |
# ifndef tan |
|
84 |
double tan(); |
|
85 |
# endif |
|
86 |
||
87 |
#endif /* not AIX */ |
|
88 |
||
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
89 |
#ifdef WIN32 |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
90 |
/* |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
91 |
* no finite(x) ? |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
92 |
* no isnan(x) ? |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
93 |
*/ |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
94 |
# ifndef finite |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
95 |
# define finite(x) 1 |
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
96 |
# endif |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
97 |
# ifndef isnan |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
98 |
# define isnan(x) 0 |
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
99 |
# endif |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
100 |
#endif |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
101 |
|
3414 | 102 |
#ifdef realIX |
103 |
/* |
|
104 |
* no finite(x) |
|
105 |
*/ |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
106 |
# ifndef finite |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
107 |
# define finite(x) 1 |
3414 | 108 |
# endif |
109 |
#endif |
|
110 |
||
3241 | 111 |
#ifndef NEXT3 |
112 |
# ifndef ceil |
|
113 |
double ceil(); |
|
114 |
double floor(); |
|
115 |
# endif |
|
116 |
#endif |
|
117 |
||
701 | 118 |
%} |
119 |
! ! |
|
120 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
121 |
!Float class methodsFor:'documentation'! |
68 | 122 |
|
88 | 123 |
copyright |
124 |
" |
|
125 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
175 | 126 |
All Rights Reserved |
88 | 127 |
|
128 |
This software is furnished under a license and may be used |
|
129 |
only in accordance with the terms of that license and with the |
|
130 |
inclusion of the above copyright notice. This software may not |
|
131 |
be provided or otherwise made available to, or used by, any |
|
132 |
other person. No title to or ownership of the software is |
|
133 |
hereby transferred. |
|
134 |
" |
|
135 |
! |
|
136 |
||
68 | 137 |
documentation |
138 |
" |
|
139 |
Floats represent rational numbers with limited precision. In ST/X, Float uses |
|
140 |
the underlying C-compilers double implementation, therefore instances of Float |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
141 |
are usually represented by the 8-byte IEEE double precision float format. |
68 | 142 |
(but there is no guaranty). |
1 | 143 |
|
68 | 144 |
Notice, that Floats are defined as Byte-array to prevent the garbage collector |
145 |
from going into the value ... otherwise I needed a special case in many places. |
|
146 |
||
147 |
Also notice, that ST/X Floats are what Doubles are in ST-80 - this may change |
|
148 |
in one of the next versions (at least on machines, which provide different float |
|
149 |
and double types in their C-compiler. |
|
150 |
||
151 |
WARNING: |
|
152 |
The layout of float instances is known by the runtime system and the compiler; |
|
153 |
you may not add instance variables here. |
|
369 | 154 |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
155 |
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
|
156 |
of arithmetic operations (even if the operands are subclass-instances). |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
157 |
(It does the float-check by probing a bit in the classes flag instVar). |
85 | 158 |
|
1892 | 159 |
Mixed mode arithmetic: |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
160 |
float op float -> float |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
161 |
float op fix -> float |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
162 |
float op integer -> float |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
163 |
float op float -> float |
1892 | 164 |
|
1295 | 165 |
[Class Variables:] |
85 | 166 |
|
1295 | 167 |
[see also:] |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
168 |
Number |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
169 |
ShortFloat Fraction FixedPoint Integer |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
170 |
FloatArray DoubleArray |
1295 | 171 |
|
172 |
[author:] |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
173 |
Claus Gittinger |
68 | 174 |
" |
2215 | 175 |
! |
176 |
||
177 |
errorHandling |
|
178 |
" |
|
179 |
Floating point error handling and signalling depends on the systems |
|
180 |
(actually: the C-runtime systems) ability to handle floating point errors. |
|
181 |
Most systems report errors by raising an OS floatingPoint exception, |
|
182 |
which is mapped to a fpExceptionInterrupt in ST/X. |
|
183 |
However, some systems do return NaN as result. |
|
184 |
||
185 |
Currently, ST/X does not care specially for these systems - it maybe added |
|
186 |
easily, if there is sufficient customer interest, though. |
|
187 |
||
188 |
Try: |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
189 |
|f1 f2| |
2215 | 190 |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
191 |
f1 := 1.0. |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
192 |
f2 := 0.0. |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
193 |
f1 / f2 |
2215 | 194 |
|
195 |
or: |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
196 |
2 arcSin |
2215 | 197 |
" |
68 | 198 |
! ! |
1 | 199 |
|
2387 | 200 |
!Float class methodsFor:'initialization'! |
201 |
||
202 |
initialize |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
203 |
DefaultPrintFormat := '.6' "/ 6 valid digits |
2387 | 204 |
|
205 |
" |
|
206 |
DefaultPrintFormat := '.9' |
|
207 |
DefaultPrintFormat := '.6' |
|
208 |
" |
|
209 |
! ! |
|
210 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
211 |
!Float class methodsFor:'instance creation'! |
1 | 212 |
|
213 |
basicNew |
|
214 |
"return a new float - here we return 0.0 |
|
215 |
- floats are usually NOT created this way ... |
|
216 |
Its implemented here to allow things like binary store & load |
|
217 |
of floats. (but even this support will go away eventually, its not |
|
218 |
a good idea to store the bits of a float - the reader might have a |
|
13 | 219 |
totally different representation - so floats will eventually be |
220 |
binary stored in a device independent format." |
|
1 | 221 |
|
222 |
%{ /* NOCONTEXT */ |
|
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
223 |
OBJ newFloat; |
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
224 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
225 |
__qMKFLOAT(newFloat, 0.0); |
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
226 |
RETURN (newFloat); |
1 | 227 |
%} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
228 |
! |
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
229 |
|
4295 | 230 |
fastFromString:aString at:startIndex |
231 |
"return the next Float from the string starting at startIndex. |
|
232 |
No spaces are skipped. |
|
233 |
||
234 |
This is a specially tuned entry (using a low-level C-call), which |
|
235 |
returns garbage if the argument string is not a valid float number. |
|
236 |
It has been added to allow higher speed string decomposition into |
|
237 |
numbers." |
|
238 |
%{ |
|
239 |
if (__isString(aString) && __isSmallInteger(startIndex)) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
240 |
char *cp = (char *)(__stringVal(aString)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
241 |
int idx = __intVal(startIndex) - 1; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
242 |
double atof(); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
243 |
double val; |
4295 | 244 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
245 |
if ((unsigned)idx < __stringSize(aString)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
246 |
val = atof(cp + idx); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
247 |
RETURN (__MKFLOAT(val)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
248 |
} |
4295 | 249 |
} |
250 |
%}. |
|
251 |
self primitiveFailed. |
|
252 |
||
253 |
" |
|
4296 | 254 |
Float fastFromString:'123.45' at:1 |
255 |
Float fastFromString:'123.45' at:2 |
|
256 |
Float fastFromString:'123.45E4' at:1 |
|
257 |
Float fastFromString:'hello123.45E4' at:6 |
|
4295 | 258 |
Float fastFromString:'12345' at:1 |
259 |
Float fastFromString:'12345' at:2 |
|
260 |
Float fastFromString:'12345' at:3 |
|
261 |
Float fastFromString:'12345' at:4 |
|
262 |
Float fastFromString:'12345' at:5 |
|
263 |
Float fastFromString:'12345' at:6 |
|
264 |
Float fastFromString:'12345' at:0 |
|
4296 | 265 |
Float fastFromString:'hello123.45E4' at:1 |
4295 | 266 |
|
267 |
Time millisecondsToRun:[ |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
268 |
100000 timesRepeat:[ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
269 |
Float readFrom:'123.45' |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
270 |
] |
4295 | 271 |
] |
272 |
" |
|
273 |
||
274 |
" |
|
275 |
Time millisecondsToRun:[ |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
276 |
100000 timesRepeat:[ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
277 |
Float fastFromString:'123.45' at:1 |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
278 |
] |
4295 | 279 |
] |
280 |
" |
|
281 |
||
282 |
||
283 |
! |
|
284 |
||
3279 | 285 |
fromVAXFloatBytes:b1 b2:b2 b3:b3 b4:b4 |
286 |
"creates a double, given the four vax float bytes to an ieee double. |
|
3427
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
287 |
For NaNs and Infinity, nil is returned. |
3279 | 288 |
" |
289 |
||
290 |
%{ /* NOCONTEXT */ |
|
291 |
||
292 |
REGISTER union { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
293 |
unsigned char b[4]; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
294 |
unsigned int l; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
295 |
float f; |
3279 | 296 |
} r; |
297 |
||
298 |
#ifdef i386 /* actually: LSBFIRST */ |
|
299 |
r.b[3] = __intVal( b2 ); |
|
300 |
r.b[2] = __intVal( b1 ); |
|
301 |
r.b[1] = __intVal( b4 ); |
|
302 |
r.b[0] = __intVal( b3 ); |
|
303 |
#else |
|
304 |
r.b[0] = __intVal( b2 ); |
|
305 |
r.b[1] = __intVal( b1 ); |
|
306 |
r.b[2] = __intVal( b4 ); |
|
307 |
r.b[3] = __intVal( b3 ); |
|
308 |
#endif |
|
309 |
if( (r.l & 0xff800000) != 0x80000000 ) |
|
310 |
{ |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
311 |
if( (r.l & 0x7f800000) > 0x01000000 ) |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
312 |
r.l -= 0x01000000; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
313 |
else |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
314 |
r.l = 0; |
3279 | 315 |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
316 |
RETURN( __MKFLOAT(r.f) ); |
3279 | 317 |
} |
318 |
%}. |
|
319 |
^ nil |
|
320 |
! |
|
321 |
||
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
322 |
readFrom:aStringOrStream onError:exceptionBlock |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
323 |
"read a float from a string" |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
324 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
325 |
|num| |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
326 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
327 |
num := super readFrom:aStringOrStream onError:nil. |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
328 |
num isNil ifTrue:[ |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
329 |
^ exceptionBlock value |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
330 |
]. |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
331 |
^ num asFloat |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
332 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
333 |
" |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
334 |
Float readFrom:'0.1' |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
335 |
Float readFrom:'0' |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
336 |
" |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
337 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
338 |
"Created: / 7.1.1998 / 16:17:19 / cg" |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
339 |
"Modified: / 7.1.1998 / 16:18:33 / cg" |
1 | 340 |
! ! |
341 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
342 |
!Float class methodsFor:'binary storage'! |
701 | 343 |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
344 |
binaryDefinitionFrom:aStream manager: manager |
701 | 345 |
|f| |
346 |
||
347 |
f := self basicNew. |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
348 |
self readBinaryIEEEDoubleFrom:aStream into:f. |
701 | 349 |
^ f |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
350 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
351 |
"Modified: 16.4.1996 / 21:23:38 / cg" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
352 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
353 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
354 |
readBinaryIEEEDoubleFrom:aStream |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
355 |
"read a float from the binary stream, aStream, |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
356 |
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
|
357 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
358 |
|f| |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
359 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
360 |
f := self basicNew. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
361 |
self readBinaryIEEEDoubleFrom:aStream into:f. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
362 |
^ f |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
363 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
364 |
"Created: 16.4.1996 / 20:59:59 / cg" |
701 | 365 |
! |
366 |
||
367 |
readBinaryIEEEDoubleFrom:aStream into:aFloat |
|
368 |
"read the receivers value from the binary stream, aStream, |
|
369 |
interpreting the next bytes as an IEEE formatted 8-byte float" |
|
370 |
||
371 |
" |
|
372 |
this implementation is wrong: does not work on non-IEEE machines |
|
373 |
(to date all machines where ST/X is running on use |
|
374 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
375 |
" |
|
3427
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
376 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
377 |
|
701 | 378 |
UninterpretedBytes isBigEndian ifFalse:[ |
379 |
"swap the bytes" |
|
380 |
8 to:1 by:-1 do:[:i | |
|
381 |
aFloat basicAt:i put:(aStream next) |
|
382 |
]. |
|
383 |
^ self |
|
384 |
]. |
|
385 |
1 to:8 do:[:i | |
|
386 |
aFloat basicAt:i put:aStream next |
|
387 |
] |
|
388 |
! |
|
389 |
||
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
390 |
readBinaryIEEESingleFrom:aStream |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
391 |
"read a float value from the binary stream, aStream, |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
392 |
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
|
393 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
394 |
|f| |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
395 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
396 |
f := self basicNew. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
397 |
self readBinaryIEEESingleFrom:aStream into:f. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
398 |
^ f |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
399 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
400 |
"Created: 16.4.1996 / 21:00:35 / cg" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
401 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
402 |
|
701 | 403 |
readBinaryIEEESingleFrom:aStream into:aFloat |
404 |
"read a float value from the binary stream, aStream, |
|
405 |
interpreting the next bytes as an IEEE formatted 4-byte float" |
|
406 |
||
407 |
" |
|
408 |
this implementation is wrong: does not work on non-IEEE machines |
|
409 |
(to date all machines where ST/X is running on use |
|
410 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
411 |
" |
|
3427
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
412 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
413 |
|
701 | 414 |
UninterpretedBytes isBigEndian ifFalse:[ |
415 |
"swap the bytes" |
|
416 |
8 to:4 by:-1 do:[:i | |
|
417 |
aFloat basicAt:i put:(aStream next) |
|
418 |
]. |
|
419 |
^ self |
|
420 |
]. |
|
421 |
1 to:4 do:[:i | |
|
422 |
aFloat basicAt:i put:aStream next |
|
423 |
] |
|
424 |
! |
|
425 |
||
426 |
storeBinaryIEEEDouble:aFloat on:aStream |
|
427 |
"store aFloat as an IEEE formatted 8-byte float |
|
428 |
onto the binary stream, aStream" |
|
429 |
||
430 |
" |
|
431 |
this implementation is wrong: does not work on non-IEEE machines |
|
432 |
(to date all machines where ST/X is running on use |
|
433 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
434 |
" |
|
3427
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
435 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
436 |
|
701 | 437 |
UninterpretedBytes isBigEndian ifFalse:[ |
438 |
"swap the bytes" |
|
439 |
8 to:1 by:-1 do:[:i | |
|
440 |
aStream nextPut:(aFloat basicAt:i). |
|
441 |
]. |
|
442 |
^ self |
|
443 |
]. |
|
444 |
1 to:8 do:[:i | |
|
445 |
aStream nextPut:(aFloat basicAt:i). |
|
446 |
]. |
|
447 |
! |
|
448 |
||
449 |
storeBinaryIEEESingle:aFloat on:aStream |
|
450 |
"store aFloat as an IEEE formatted 4-byte float |
|
451 |
onto the binary stream, aStream" |
|
452 |
||
453 |
" |
|
454 |
this implementation is wrong: does not work on non-IEEE machines |
|
455 |
(to date all machines where ST/X is running on use |
|
456 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
457 |
" |
|
3427
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
458 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
459 |
|
701 | 460 |
UninterpretedBytes isBigEndian ifFalse:[ |
461 |
"swap the bytes" |
|
462 |
8 to:4 by:-1 do:[:i | |
|
463 |
aStream nextPut:(aFloat basicAt:i). |
|
464 |
]. |
|
465 |
^ self |
|
466 |
]. |
|
467 |
1 to:4 do:[:i | |
|
468 |
aStream nextPut:(aFloat basicAt:i). |
|
469 |
] |
|
470 |
! ! |
|
471 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
472 |
!Float class methodsFor:'constants'! |
1 | 473 |
|
3945
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
474 |
NaN |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
475 |
"return the constant NaN (not a Number). |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
476 |
Do not use (yet) - for now, this is only defined for a |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
477 |
few selected architectures." |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
478 |
|
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
479 |
%{ |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
480 |
#if defined(LINUX) && defined(i386) |
3955 | 481 |
# ifdef NAN |
482 |
RETURN (__MKFLOAT(NAN)); |
|
483 |
# else |
|
3945
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
484 |
RETURN (__MKFLOAT(_SNAN)); |
3955 | 485 |
# endif |
3945
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
486 |
#endif |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
487 |
%}. |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
488 |
^ nil |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
489 |
|
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
490 |
" |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
491 |
Float NaN |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
492 |
Float NaN + 0.0 |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
493 |
Float NaN + Float NaN |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
494 |
0.0 + Float NaN |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
495 |
" |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
496 |
! |
1745e97364cb
added preliminary version of NaN
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
497 |
|
701 | 498 |
pi |
1260 | 499 |
"return the constant pi as Float" |
1 | 500 |
|
3244 | 501 |
"/ dont expect this many valid digits on all machines; |
502 |
"/ The actual precision is very CPU specific. |
|
503 |
||
504 |
^ 3.14159265358979323846264338327950288 |
|
1260 | 505 |
|
506 |
"Modified: 23.4.1996 / 09:27:02 / cg" |
|
1 | 507 |
! |
508 |
||
509 |
unity |
|
1260 | 510 |
"return the neutral element for multiplication (1.0) as Float" |
1 | 511 |
|
512 |
^ 1.0 |
|
1260 | 513 |
|
514 |
"Modified: 23.4.1996 / 09:27:09 / cg" |
|
1 | 515 |
! |
516 |
||
701 | 517 |
zero |
1260 | 518 |
"return the neutral element for addition (0.0) as Float" |
1 | 519 |
|
701 | 520 |
^ 0.0 |
1260 | 521 |
|
522 |
"Modified: 23.4.1996 / 09:27:15 / cg" |
|
1 | 523 |
! ! |
524 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
525 |
!Float class methodsFor:'queries'! |
3 | 526 |
|
527 |
isBuiltInClass |
|
1264 | 528 |
"return true if this class is known by the run-time-system. |
529 |
Here, true is returned for myself, false for subclasses." |
|
3 | 530 |
|
531 |
^ self == Float |
|
1264 | 532 |
|
533 |
"Modified: 23.4.1996 / 15:59:04 / cg" |
|
3427
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
534 |
! |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
535 |
|
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
536 |
isIEEEFormat |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
537 |
"return true, if this machine represents floats in IEEE format. |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
538 |
Currently, no support is provided for non-ieee machines |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
539 |
to convert their floats into this (which is only relevant, |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
540 |
if such a machine wants to send floats as binary to some other |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
541 |
machine). |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
542 |
Machines with non-IEEE format are VAXed and IBM370-type systems |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
543 |
(among others). Today, most systems use IEEE format floats." |
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
544 |
|
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
545 |
^ true "/ this may be a lie |
3 | 546 |
! ! |
547 |
||
1 | 548 |
!Float methodsFor:'arithmetic'! |
549 |
||
701 | 550 |
* aNumber |
551 |
"return the product of the receiver and the argument, aNumber" |
|
552 |
||
553 |
%{ /* NOCONTEXT */ |
|
554 |
||
555 |
OBJ newFloat; |
|
556 |
double result; |
|
557 |
||
558 |
if (__isSmallInteger(aNumber)) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
559 |
result = __floatVal(self) * (double)(__intVal(aNumber)); |
701 | 560 |
retResult: |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
561 |
__qMKFLOAT(newFloat, result); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
562 |
RETURN ( newFloat ); |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
563 |
} else if (__isFloatLike(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
564 |
result = __floatVal(self) * __floatVal(aNumber); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
565 |
goto retResult; |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
566 |
} else if (__isShortFloat(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
567 |
result = __floatVal(self) * (double)(__shortFloatVal(aNumber)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
568 |
goto retResult; |
701 | 569 |
} |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
570 |
%}. |
701 | 571 |
^ aNumber productFromFloat:self |
572 |
! |
|
573 |
||
1 | 574 |
+ aNumber |
575 |
"return the sum of the receiver and the argument, aNumber" |
|
576 |
||
577 |
%{ /* NOCONTEXT */ |
|
13 | 578 |
|
1 | 579 |
OBJ newFloat; |
580 |
double result; |
|
581 |
||
250 | 582 |
if (__isSmallInteger(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
583 |
result = __floatVal(self) + (double)(__intVal(aNumber)); |
1 | 584 |
retResult: |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
585 |
__qMKFLOAT(newFloat, result); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
586 |
RETURN ( newFloat ); |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
587 |
} else if (__isFloatLike(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
588 |
result = __floatVal(self) + __floatVal(aNumber); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
589 |
goto retResult; |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
590 |
} else if (__isShortFloat(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
591 |
result = __floatVal(self) + (double)(__shortFloatVal(aNumber)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
592 |
goto retResult; |
1 | 593 |
} |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
594 |
%}. |
1 | 595 |
^ aNumber sumFromFloat:self |
596 |
! |
|
597 |
||
598 |
- aNumber |
|
599 |
"return the difference of the receiver and the argument, aNumber" |
|
600 |
||
601 |
%{ /* NOCONTEXT */ |
|
13 | 602 |
|
1 | 603 |
OBJ newFloat; |
604 |
double result; |
|
605 |
||
250 | 606 |
if (__isSmallInteger(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
607 |
result = __floatVal(self) - (double)(__intVal(aNumber)); |
1 | 608 |
retResult: |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
609 |
__qMKFLOAT(newFloat, result); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
610 |
RETURN ( newFloat ); |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
611 |
} else if (__isFloatLike(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
612 |
result = __floatVal(self) - __floatVal(aNumber); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
613 |
goto retResult; |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
614 |
} else if (__isShortFloat(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
615 |
result = __floatVal(self) - (double)(__shortFloatVal(aNumber)); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
616 |
goto retResult; |
1 | 617 |
} |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
618 |
%}. |
1 | 619 |
^ aNumber differenceFromFloat:self |
620 |
! |
|
621 |
||
622 |
/ aNumber |
|
623 |
"return the quotient of the receiver and the argument, aNumber" |
|
624 |
||
625 |
%{ /* NOCONTEXT */ |
|
626 |
||
627 |
OBJ newFloat; |
|
628 |
double result, val; |
|
629 |
||
250 | 630 |
if (__isSmallInteger(aNumber)) { |
4454
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
631 |
if (aNumber != __MKSMALLINT(0)) { |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
632 |
result = __floatVal(self) / ( (double)__intVal(aNumber)) ; |
1 | 633 |
retResult: |
4454
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
634 |
__qMKFLOAT(newFloat, result); |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
635 |
RETURN ( newFloat ); |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
636 |
} |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
637 |
} else if (__isFloatLike(aNumber)) { |
4454
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
638 |
val = __floatVal(aNumber); |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
639 |
if (val != 0.0) { |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
640 |
result = __floatVal(self) / val; |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
641 |
goto retResult; |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
642 |
} |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
643 |
} else if (__isShortFloat(aNumber)) { |
4454
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
644 |
val = (double)(__shortFloatVal(aNumber)); |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
645 |
if (val != 0.0) { |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
646 |
result = __floatVal(self) / val; |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
647 |
goto retResult; |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
648 |
} |
1 | 649 |
} |
3530
a1af5dafc3ee
float op shortFloat added inline.
Claus Gittinger <cg@exept.de>
parents:
3472
diff
changeset
|
650 |
%}. |
1 | 651 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
4454
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
652 |
" |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
653 |
No, you shalt not divide by zero |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
654 |
" |
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
655 |
^ DivisionByZeroSignal raiseRequest. |
1 | 656 |
]. |
657 |
^ aNumber quotientFromFloat:self |
|
658 |
! |
|
659 |
||
660 |
negated |
|
661 |
"return myself negated" |
|
662 |
||
663 |
%{ /* NOCONTEXT */ |
|
13 | 664 |
|
3 | 665 |
OBJ newFloat; |
1133 | 666 |
double rslt = - __floatVal(self); |
3 | 667 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
668 |
__qMKFLOAT(newFloat, rslt); |
3 | 669 |
RETURN ( newFloat ); |
1 | 670 |
%} |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
671 |
! |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
672 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
673 |
uncheckedDivide:aNumber |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
674 |
"return the quotient of the receiver and the argument, aNumber. |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
675 |
Do not check for divide by zero (return NaN or infinity)" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
676 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
677 |
%{ /* NOCONTEXT */ |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
678 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
679 |
OBJ newFloat; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
680 |
double result, val; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
681 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
682 |
if (__isSmallInteger(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
683 |
result = __floatVal(self) / ( (double)__intVal(aNumber)) ; |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
684 |
retResult: |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
685 |
__qMKFLOAT(newFloat, result); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
686 |
RETURN ( newFloat ); |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
687 |
} else if (__isFloatLike(aNumber)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
688 |
val = __floatVal(aNumber); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
689 |
result = __floatVal(self) / val; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
690 |
goto retResult; |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
691 |
} |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
692 |
%} |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
693 |
. |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
694 |
^ aNumber quotientFromFloat:self |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
695 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
696 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
697 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
698 |
0.0 uncheckedDivide:0.0 |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
699 |
1.0 uncheckedDivide:0.0 |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
700 |
" |
1 | 701 |
! ! |
702 |
||
701 | 703 |
!Float methodsFor:'binary storage'! |
704 |
||
705 |
storeBinaryDefinitionOn:stream manager:manager |
|
1260 | 706 |
"store the receiver in a binary format on stream. |
707 |
This is an internal interface for binary storage mechanism." |
|
708 |
||
701 | 709 |
manager putIdOfClass:(self class) on:stream. |
710 |
Float storeBinaryIEEEDouble:self on:stream. |
|
1260 | 711 |
|
712 |
"Modified: 23.4.1996 / 09:29:48 / cg" |
|
701 | 713 |
! ! |
714 |
||
715 |
!Float methodsFor:'coercion and converting'! |
|
1 | 716 |
|
3014 | 717 |
asDouble |
718 |
"ST80 compatibility: return a float with same value - thats me" |
|
719 |
||
720 |
^ self |
|
721 |
! |
|
722 |
||
701 | 723 |
asFloat |
724 |
"return a float with same value - thats me" |
|
725 |
||
726 |
^ self |
|
727 |
! |
|
728 |
||
729 |
asInteger |
|
730 |
"return an integer with same value - might truncate" |
|
731 |
||
1 | 732 |
%{ /* NOCONTEXT */ |
1670 | 733 |
double dVal; |
13 | 734 |
|
1670 | 735 |
dVal = __floatVal(self); |
3427
ba90490c94b6
added query for IEE format (for future use)
Claus Gittinger <cg@exept.de>
parents:
3414
diff
changeset
|
736 |
|
1670 | 737 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
738 |
RETURN ( __MKSMALLINT( (INT)dVal) ); |
701 | 739 |
} |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
740 |
%}. |
701 | 741 |
^ super asInteger |
742 |
||
743 |
"12345.0 asInteger" |
|
744 |
"1e15 asInteger" |
|
1 | 745 |
! |
746 |
||
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
747 |
asShortFloat |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
748 |
"return a shortFloat with same value as receiver" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
749 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
750 |
%{ /* NOCONTEXT */ |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
751 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
752 |
OBJ dummy = @global(ShortFloat); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
753 |
OBJ newFloat; |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
754 |
float fVal = (float)__floatVal(self); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
755 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
756 |
__qMKSFLOAT(newFloat, fVal); |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
757 |
RETURN ( newFloat ); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
758 |
%} |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
759 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
760 |
|
701 | 761 |
coerce:aNumber |
762 |
"return aNumber converted into receivers type" |
|
1 | 763 |
|
701 | 764 |
^ aNumber asFloat |
765 |
! |
|
13 | 766 |
|
701 | 767 |
generality |
768 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
769 |
||
770 |
^ 80 |
|
1 | 771 |
! ! |
772 |
||
773 |
!Float methodsFor:'comparing'! |
|
774 |
||
775 |
< aNumber |
|
776 |
"return true, if the argument is greater" |
|
777 |
||
778 |
%{ /* NOCONTEXT */ |
|
13 | 779 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
780 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
781 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
782 |
RETURN ( (__floatVal(self) < (double)(__intVal(aNumber))) ? true : false ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
783 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
784 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
785 |
RETURN ( (__floatVal(self) < __floatVal(aNumber)) ? true : false ); |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
786 |
} |
1 | 787 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
788 |
%}. |
1 | 789 |
^ aNumber lessFromFloat:self |
790 |
! |
|
791 |
||
792 |
<= aNumber |
|
793 |
"return true, if the argument is greater or equal" |
|
794 |
||
795 |
%{ /* NOCONTEXT */ |
|
13 | 796 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
797 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
798 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
799 |
RETURN ( (__floatVal(self) <= (double)(__intVal(aNumber))) ? true : false ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
800 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
801 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
802 |
RETURN ( (__floatVal(self) <= __floatVal(aNumber)) ? true : false ); |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
803 |
} |
1 | 804 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
805 |
%}. |
1 | 806 |
^ self retry:#<= coercing:aNumber |
807 |
! |
|
808 |
||
809 |
= aNumber |
|
175 | 810 |
"return true, if the arguments value are equal by value" |
1 | 811 |
|
812 |
%{ /* NOCONTEXT */ |
|
13 | 813 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
814 |
if (aNumber != nil) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
815 |
if (__isSmallInteger(aNumber)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
816 |
RETURN ( (__floatVal(self) == (double)(__intVal(aNumber))) ? true : false ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
817 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
818 |
if (__qIsFloatLike(aNumber)) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
819 |
RETURN ( (__floatVal(self) == __floatVal(aNumber)) ? true : false ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
820 |
} |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
821 |
if (__qClass(aNumber)==ShortFloat) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
822 |
RETURN ( (__floatVal(self) == (double)(__shortFloatVal(aNumber))) ? true : false ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
823 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
824 |
} else { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
825 |
RETURN (false); |
1 | 826 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
827 |
%}. |
1 | 828 |
^ self retry:#= coercing:aNumber |
829 |
! |
|
830 |
||
701 | 831 |
> aNumber |
832 |
"return true, if the argument is less" |
|
1 | 833 |
|
834 |
%{ /* NOCONTEXT */ |
|
13 | 835 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
836 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
837 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
838 |
RETURN ( (__floatVal(self) > (double)(__intVal(aNumber))) ? true : false ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
839 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
840 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
841 |
RETURN ( (__floatVal(self) > __floatVal(aNumber)) ? true : false ); |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
842 |
} |
1 | 843 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
844 |
%}. |
701 | 845 |
^ self retry:#> coercing:aNumber |
846 |
! |
|
847 |
||
848 |
>= aNumber |
|
849 |
"return true, if the argument is less or equal" |
|
850 |
||
851 |
%{ /* NOCONTEXT */ |
|
852 |
||
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
853 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
854 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
855 |
RETURN ( (__floatVal(self) >= (double)(__intVal(aNumber))) ? true : false ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
856 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
857 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
858 |
RETURN ( (__floatVal(self) >= __floatVal(aNumber)) ? true : false ); |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
859 |
} |
701 | 860 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
861 |
%}. |
701 | 862 |
^ self retry:#>= coercing:aNumber |
92 | 863 |
! |
864 |
||
865 |
hash |
|
866 |
"return a number for hashing; redefined, since floats compare |
|
867 |
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same |
|
868 |
as 3 hash." |
|
869 |
||
305 | 870 |
|i| |
92 | 871 |
|
872 |
(self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[ |
|
175 | 873 |
i := self asInteger. |
874 |
self = i ifTrue:[ |
|
875 |
^ i hash |
|
876 |
]. |
|
92 | 877 |
]. |
878 |
||
879 |
" |
|
305 | 880 |
mhmh take some of my value-bits to hash on |
92 | 881 |
" |
305 | 882 |
^ (((self basicAt:8) bitAnd:16r3F) bitShift:24) + |
883 |
((self basicAt:7) bitShift:16) + |
|
884 |
((self basicAt:6) bitShift:8) + |
|
885 |
(self basicAt:5) |
|
92 | 886 |
|
887 |
" |
|
888 |
3 hash |
|
889 |
3.0 hash |
|
890 |
3.1 hash |
|
891 |
3.14159 hash |
|
892 |
31.4159 hash |
|
893 |
3.141591 hash |
|
894 |
1.234567890123456 hash |
|
895 |
1.234567890123457 hash |
|
896 |
Set withAll:#(3 3.0 99 99.0 3.1415) |
|
897 |
" |
|
1 | 898 |
! |
899 |
||
701 | 900 |
~= aNumber |
901 |
"return true, if the arguments value are not equal" |
|
1 | 902 |
|
903 |
%{ /* NOCONTEXT */ |
|
904 |
||
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
905 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
906 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
907 |
RETURN ( (__floatVal(self) != (double)(__intVal(aNumber))) ? true : false ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
908 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
909 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
910 |
RETURN ( (__floatVal(self) != __floatVal(aNumber)) ? true : false ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
911 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
912 |
} else { |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
913 |
RETURN (true); |
1 | 914 |
} |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
915 |
%}. |
701 | 916 |
^ self retry:#~= coercing:aNumber |
1 | 917 |
! ! |
918 |
||
919 |
!Float methodsFor:'mathematical functions'! |
|
920 |
||
701 | 921 |
arcCos |
922 |
"return the arccosine of myself as radians" |
|
923 |
||
924 |
%{ /* NOCONTEXT */ |
|
925 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
926 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
927 |
OBJ newFloat; |
701 | 928 |
|
929 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
930 |
rslt = acos(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
931 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
932 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
933 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
934 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
935 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
936 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
937 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
938 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
939 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
940 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
941 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
942 |
selector:#arcCos |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
943 |
errorString:'bad receiver in arcCos' |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
944 |
|
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
945 |
" |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
946 |
-10 arcCos |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
947 |
1 arcCos |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
948 |
" |
701 | 949 |
! |
950 |
||
951 |
arcSin |
|
952 |
"return the arcsine of myself as radians" |
|
953 |
||
954 |
%{ /* NOCONTEXT */ |
|
955 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
956 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
957 |
OBJ newFloat; |
701 | 958 |
|
959 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
960 |
rslt = asin(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
961 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
962 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
963 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
964 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
965 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
966 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
967 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
968 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
969 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
970 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
971 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
972 |
selector:#arcSin |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
973 |
errorString:'bad receiver in arcSin' |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
974 |
|
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
975 |
" |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
976 |
-10 arcSin |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
977 |
1 arcSin |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
978 |
" |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
979 |
|
701 | 980 |
! |
981 |
||
982 |
arcTan |
|
983 |
"return the arctangent of myself as radians" |
|
984 |
||
985 |
%{ /* NOCONTEXT */ |
|
986 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
987 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
988 |
OBJ newFloat; |
701 | 989 |
|
990 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
991 |
rslt = atan(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
992 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
993 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
994 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
995 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
996 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
997 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
998 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
999 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1000 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1001 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1002 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1003 |
selector:#arcTan |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1004 |
errorString:'bad receiver in arcTan' |
701 | 1005 |
! |
1006 |
||
1007 |
cos |
|
1008 |
"return the cosine of myself interpreted as radians" |
|
1009 |
||
1010 |
%{ /* NOCONTEXT */ |
|
1011 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1012 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1013 |
OBJ newFloat; |
701 | 1014 |
|
1015 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1016 |
rslt = cos(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1017 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1018 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1019 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1020 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1021 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1022 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1023 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1024 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1025 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1026 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1027 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1028 |
selector:#cos |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1029 |
errorString:'bad receiver in cos' |
701 | 1030 |
! |
1031 |
||
1032 |
exp |
|
1033 |
"return e raised to the power of the receiver" |
|
1034 |
||
1035 |
%{ /* NOCONTEXT */ |
|
1036 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1037 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1038 |
OBJ newFloat; |
701 | 1039 |
|
1040 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1041 |
rslt = exp(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1042 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1043 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1044 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1045 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1046 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1047 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1048 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1049 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1050 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1051 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1052 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1053 |
selector:#exp |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1054 |
errorString:'bad receiver in exp' |
701 | 1055 |
! |
1056 |
||
1 | 1057 |
ln |
1058 |
"return the natural logarithm of myself" |
|
1059 |
||
1060 |
%{ /* NOCONTEXT */ |
|
1061 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1062 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1063 |
OBJ newFloat; |
1 | 1064 |
|
1065 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1066 |
rslt = log(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1067 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1068 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1069 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1070 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1071 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1072 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1073 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1074 |
%}. |
142 | 1075 |
" |
1076 |
an invalid value for logarithm |
|
1077 |
" |
|
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1078 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1079 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1080 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1081 |
selector:#ln |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1082 |
errorString:'bad receiver in ln' |
1 | 1083 |
! |
1084 |
||
1085 |
raisedTo:aNumber |
|
1086 |
"return self raised to the power of aNumber" |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1087 |
|
1 | 1088 |
|n| |
1089 |
||
1090 |
n := aNumber asFloat. |
|
1091 |
%{ |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1092 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1093 |
OBJ newFloat; |
1 | 1094 |
|
283 | 1095 |
if (__isFloatLike(n)) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1096 |
errno = 0; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1097 |
rslt = pow(__floatVal(self), __floatVal(n)); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1098 |
#if 0 |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1099 |
errno = 0; /* XXXX */ |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1100 |
#endif |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1101 |
#ifdef LINUX /* and maybe others */ |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1102 |
if (! isnan(rslt)) |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1103 |
#endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1104 |
if (errno == 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1105 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1106 |
RETURN ( newFloat ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1107 |
} |
1 | 1108 |
} |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1109 |
%}. |
142 | 1110 |
" |
1111 |
an invalid argument (not convertable to float ?) |
|
1112 |
" |
|
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1113 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1114 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1115 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1116 |
selector:#raisedTo: |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1117 |
arg:aNumber |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1118 |
errorString:'bad receiver/arg in raisedTo:' |
1 | 1119 |
! |
1120 |
||
1121 |
sin |
|
1122 |
"return the sine of myself interpreted as radians" |
|
1123 |
||
1124 |
%{ /* NOCONTEXT */ |
|
1125 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1126 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1127 |
OBJ newFloat; |
1 | 1128 |
|
1129 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1130 |
rslt = sin(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1131 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1132 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1133 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1134 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1135 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1136 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1137 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1138 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1139 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1140 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1141 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1142 |
selector:#sin |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1143 |
errorString:'bad receiver in sin' |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1144 |
|
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1145 |
|
1 | 1146 |
! |
1147 |
||
1148 |
sqrt |
|
1149 |
"return the square root of myself" |
|
1150 |
||
1151 |
%{ /* NOCONTEXT */ |
|
1152 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1153 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1154 |
OBJ newFloat; |
1 | 1155 |
|
3889
3466554b639f
manually check receiver for beeing >= 0 under WINDOWS
Claus Gittinger <cg@exept.de>
parents:
3632
diff
changeset
|
1156 |
#ifdef WIN32 |
3466554b639f
manually check receiver for beeing >= 0 under WINDOWS
Claus Gittinger <cg@exept.de>
parents:
3632
diff
changeset
|
1157 |
if (__floatVal(self) >= 0.0) |
3466554b639f
manually check receiver for beeing >= 0 under WINDOWS
Claus Gittinger <cg@exept.de>
parents:
3632
diff
changeset
|
1158 |
#endif |
3466554b639f
manually check receiver for beeing >= 0 under WINDOWS
Claus Gittinger <cg@exept.de>
parents:
3632
diff
changeset
|
1159 |
{ |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1160 |
errno = 0; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1161 |
rslt = sqrt(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1162 |
#ifdef LINUX /* and maybe others */ |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1163 |
if (! isnan(rslt)) |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1164 |
#endif |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1165 |
if (errno == 0) { |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1166 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1167 |
RETURN ( newFloat ); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1168 |
} |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1169 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1170 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1171 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1172 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1173 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1174 |
selector:#sqrt |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1175 |
errorString:'bad receiver in sqrt' |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1176 |
|
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1177 |
" |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1178 |
10 sqrt |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1179 |
-10 sqrt |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1180 |
" |
701 | 1181 |
! |
258 | 1182 |
|
701 | 1183 |
tan |
1184 |
"return the tangent of myself interpreted as radians" |
|
258 | 1185 |
|
1186 |
%{ /* NOCONTEXT */ |
|
1187 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1188 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1189 |
OBJ newFloat; |
44 | 1190 |
|
701 | 1191 |
errno = 0; |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1192 |
rslt = tan(__floatVal(self)); |
3399
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1193 |
#ifdef LINUX /* and maybe others */ |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1194 |
if (! isnan(rslt)) |
4f45ebb7bc60
oops - linux does not set errNo on some domainErrors;
Claus Gittinger <cg@exept.de>
parents:
3395
diff
changeset
|
1195 |
#endif |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1196 |
if (errno == 0) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1197 |
__qMKFLOAT(newFloat, rslt); |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1198 |
RETURN ( newFloat ); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1199 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
1200 |
%}. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1201 |
^ self class |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1202 |
raise:#domainErrorSignal |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1203 |
receiver:self |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1204 |
selector:#tan |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1205 |
errorString:'bad receiver in tan' |
13 | 1206 |
! ! |
1207 |
||
92 | 1208 |
!Float methodsFor:'printing & storing'! |
1 | 1209 |
|
1210 |
printString |
|
2358 | 1211 |
"return a printed representation of the receiver; |
1212 |
if not specified otherwise (by setting DefaultPrintFormat), |
|
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3163
diff
changeset
|
1213 |
6 valid digits are printed. |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3163
diff
changeset
|
1214 |
LimitedPrecisonReal and its subclasses use #printString instead of |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3163
diff
changeset
|
1215 |
#printOn: as basic print mechanism." |
1 | 1216 |
|
1217 |
%{ /* NOCONTEXT */ |
|
1218 |
||
13 | 1219 |
char buffer[64]; |
1 | 1220 |
REGISTER char *cp; |
314 | 1221 |
OBJ s; |
2358 | 1222 |
char *fmt; |
1223 |
char fmtBuffer[20]; |
|
1224 |
||
1225 |
if (__isString(@global(DefaultPrintFormat))) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1226 |
fmt = (char *) __stringVal(@global(DefaultPrintFormat)); |
2358 | 1227 |
} else { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1228 |
/* |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1229 |
* in case we get called before #initialize ... |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1230 |
*/ |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1231 |
fmt = ".6"; |
2358 | 1232 |
} |
1233 |
||
1234 |
/* |
|
1235 |
* build a printf format string |
|
1236 |
*/ |
|
1237 |
fmtBuffer[0] = '%'; |
|
1238 |
strncpy(fmtBuffer+1, fmt, 10); |
|
1239 |
#ifdef SYSV |
|
1240 |
strcat(fmtBuffer, "lg"); |
|
1241 |
#else |
|
1242 |
strcat(fmtBuffer, "G"); |
|
1243 |
#endif |
|
314 | 1244 |
|
2358 | 1245 |
sprintf(buffer, fmtBuffer, __floatVal(self)); |
1 | 1246 |
|
1247 |
/* |
|
13 | 1248 |
* kludge to make integral float f prints as "f.0" (not as "f" as printf does) |
1 | 1249 |
* (i.e. look if string contains '.' or 'e' and append '.0' if not) |
1250 |
*/ |
|
1251 |
for (cp = buffer; *cp; cp++) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1252 |
if ((*cp == '.') || (*cp == 'e')) break; |
1 | 1253 |
} |
1254 |
if (! *cp) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1255 |
*cp++ = '.'; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1256 |
*cp++ = '0'; |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1257 |
*cp = '\0'; |
1 | 1258 |
} |
1259 |
||
1133 | 1260 |
s = __MKSTRING(buffer COMMA_SND); |
314 | 1261 |
if (s != nil) { |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1262 |
RETURN (s); |
314 | 1263 |
} |
1264 |
%}. |
|
1265 |
" |
|
1266 |
memory allocation (for the new string) failed. |
|
1267 |
When we arrive here, there was no memory, even after a garbage collect. |
|
1268 |
This means, that the VM wanted to get some more memory from the |
|
1269 |
OS, which was not kind enough to give it. |
|
1270 |
Bad luck - you should increase the swap space on your machine. |
|
1271 |
" |
|
1272 |
^ ObjectMemory allocationFailureSignal raise. |
|
1273 |
||
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1274 |
" |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1275 |
1.0 printString |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1276 |
1.234 printString |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1277 |
1e10 printString |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1278 |
1.2e3 printString |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1279 |
1.2e30 printString |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1280 |
(1.0 uncheckedDivide:0) printString |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1281 |
(0.0 uncheckedDivide:0) printString |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1282 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1283 |
|
1 | 1284 |
! |
1285 |
||
1286 |
printfPrintString:formatString |
|
1287 |
"non-portable: return a printed representation of the receiver |
|
1288 |
as specified by formatString, which is defined by printf. |
|
31 | 1289 |
If you use this, be aware, that specifying doubles differs on |
1 | 1290 |
systems; on SYSV machines you have to give something like %lf, |
13 | 1291 |
while on BSD systems the format string has to be %F. |
31 | 1292 |
Also, the resulting string may not be longer than 255 bytes - |
54 | 1293 |
since thats the (static) size of the buffer. |
1294 |
This method is NONSTANDARD and may be removed without notice." |
|
1 | 1295 |
|
13 | 1296 |
%{ /* STACK: 400 */ |
1 | 1297 |
char buffer[256]; |
314 | 1298 |
OBJ s; |
1 | 1299 |
|
54 | 1300 |
if (__isString(formatString)) { |
1133 | 1301 |
sprintf(buffer, __stringVal(formatString), __floatVal(self)); |
369 | 1302 |
|
1133 | 1303 |
s = __MKSTRING(buffer COMMA_SND); |
343 | 1304 |
if (s != nil) { |
1305 |
RETURN (s); |
|
1306 |
} |
|
1 | 1307 |
} |
314 | 1308 |
%}. |
1 | 1309 |
self primitiveFailed |
1310 |
||
1311 |
"Float pi printfPrintString:'%%lg -> %lg'" |
|
1312 |
"Float pi printfPrintString:'%%lf -> %lf'" |
|
1313 |
"Float pi printfPrintString:'%%7.5lg -> %7.5lg'" |
|
1314 |
"Float pi printfPrintString:'%%7.5lf -> %7.5lf'" |
|
1315 |
"Float pi printfPrintString:'%%G -> %G'" |
|
1316 |
"Float pi printfPrintString:'%%F -> %F'" |
|
1317 |
"Float pi printfPrintString:'%%7.5G -> %7.5G'" |
|
1318 |
"Float pi printfPrintString:'%%7.5F -> %7.5F'" |
|
1319 |
! ! |
|
701 | 1320 |
|
1321 |
!Float methodsFor:'private accessing'! |
|
1322 |
||
1323 |
basicAt:index |
|
1324 |
"return an internal byte of the float. |
|
1325 |
The value returned here depends on byte order, float representation etc. |
|
1326 |
Therefore, this method should be used strictly private. |
|
1327 |
||
1328 |
Notice: |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1329 |
the need to redefine this method here is due to the |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1330 |
inability of many machines to store floats in non-double aligned memory. |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1331 |
Therefore, on some machines, the first 4 bytes of a float are left unused, |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1332 |
and the actual float is stored at index 5 .. 12. |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1333 |
To hide this at one place, this method knows about that, and returns |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1334 |
values as if this filler wasnt present." |
701 | 1335 |
|
1336 |
%{ /* NOCONTEXT */ |
|
1337 |
||
1338 |
register int indx; |
|
1339 |
unsigned char *cp; |
|
1340 |
||
1341 |
/* |
|
1342 |
* notice the missing test for self being a nonNilObject - |
|
1343 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
1344 |
* and SmallInteger |
|
1345 |
*/ |
|
1346 |
if (__isSmallInteger(index)) { |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1347 |
indx = __intVal(index) - 1; |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1348 |
if (((unsigned)(indx)) < sizeof(double)) { |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1349 |
cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue)); |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1350 |
RETURN ( __MKSMALLINT(cp[indx] & 0xFF) ); |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1351 |
} |
701 | 1352 |
} |
1353 |
%}. |
|
1354 |
index isInteger ifFalse:[ |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1355 |
^ self indexNotInteger |
701 | 1356 |
]. |
1357 |
^ self subscriptBoundsError:index |
|
1358 |
! |
|
1359 |
||
1360 |
basicAt:index put:value |
|
1361 |
"set an internal byte of the float. |
|
1362 |
The value to be stored here depends on byte order, float representation etc. |
|
1363 |
Therefore, this method should be used strictly private. |
|
1364 |
||
1365 |
Notice: |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1366 |
the need to redefine this method here is due to the |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1367 |
inability of many machines to store floats in non-double aligned memory. |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1368 |
Therefore, on some machines, the first 4 bytes of a float are left unused, |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1369 |
and the actual float is stored at index 5 .. 12. |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1370 |
To hide this at one place, this method knows about that, and returns |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1371 |
values as if this filler wasnt present." |
701 | 1372 |
|
1373 |
%{ /* NOCONTEXT */ |
|
1374 |
register int indx, val; |
|
1375 |
unsigned char *cp; |
|
1376 |
||
1377 |
/* |
|
1378 |
* notice the missing test for self being a nonNilObject - |
|
1379 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
1380 |
* and SmallInteger |
|
1381 |
*/ |
|
1382 |
if (__bothSmallInteger(index, value)) { |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1383 |
val = __intVal(value); |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1384 |
if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1385 |
indx = __intVal(index) - 1; |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1386 |
if (((unsigned)(indx)) < sizeof(double)) { |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1387 |
cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue)); |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1388 |
cp[indx] = val; |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1389 |
RETURN ( value ); |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1390 |
} |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1391 |
} |
701 | 1392 |
} |
1393 |
%}. |
|
1394 |
index isInteger ifFalse:[ |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1395 |
^ self indexNotInteger |
701 | 1396 |
]. |
1397 |
value isInteger ifFalse:[ |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1398 |
" |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1399 |
the object to store should be an integer number |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1400 |
" |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1401 |
^ self elementNotInteger |
701 | 1402 |
]. |
1403 |
(value between:0 and:255) ifFalse:[ |
|
4387
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1404 |
" |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1405 |
the object to store must be a bytes value |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1406 |
" |
8522ae8fa0b2
can do bounds check with unsigned compare in #at: / #at:put:
Claus Gittinger <cg@exept.de>
parents:
4305
diff
changeset
|
1407 |
^ self elementBoundsError |
701 | 1408 |
]. |
1409 |
^ self subscriptBoundsError:index |
|
1410 |
! ! |
|
1411 |
||
3896 | 1412 |
!Float methodsFor:'special access'! |
1413 |
||
1414 |
exponent |
|
1415 |
"extract a normalized floats exponent. |
|
1416 |
The returned value depends on the float-representation of |
|
1417 |
the underlying machine and is therefore highly unportable. |
|
1418 |
This is not for general use. |
|
1419 |
This assumes that the mantissa is normalized to |
|
1420 |
0.5 .. 1.0 and the floats value is mantissa * 2^exp" |
|
1421 |
||
1422 |
%{ /* NOCONTEXT */ |
|
1423 |
||
1424 |
double frexp(); |
|
1425 |
double frac; |
|
1426 |
INT exp; |
|
1427 |
||
1428 |
errno = 0; |
|
1429 |
frac = frexp(__floatVal(self), &exp); |
|
1430 |
if (errno == 0) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1431 |
RETURN (__MKSMALLINT(exp)); |
3896 | 1432 |
} |
1433 |
%}. |
|
1434 |
^ self primitiveFailed |
|
1435 |
||
1436 |
" |
|
1437 |
1.0 exponent |
|
1438 |
2.0 exponent |
|
1439 |
3.0 exponent |
|
1440 |
4.0 exponent |
|
1441 |
0.5 exponent |
|
1442 |
0.4 exponent |
|
1443 |
0.25 exponent |
|
1444 |
0.00000011111 exponent |
|
1445 |
" |
|
1446 |
! |
|
1447 |
||
1448 |
mantissa |
|
1449 |
"extract a normalized floats mantissa. |
|
1450 |
The returned value depends on the float-representation of |
|
1451 |
the underlying machine and is therefore highly unportable. |
|
1452 |
This is not for general use. |
|
1453 |
This assumes that the mantissa is normalized to |
|
1454 |
0.5 .. 1.0 and the floats value is mantissa * 2^exp" |
|
1455 |
||
1456 |
%{ /* NOCONTEXT */ |
|
1457 |
||
1458 |
double frexp(); |
|
1459 |
double frac; |
|
1460 |
INT exp; |
|
1461 |
||
1462 |
errno = 0; |
|
1463 |
frac = frexp(__floatVal(self), &exp); |
|
1464 |
if (errno == 0) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1465 |
RETURN (__MKFLOAT(frac)); |
3896 | 1466 |
} |
1467 |
%}. |
|
1468 |
^ self primitiveFailed |
|
1469 |
||
1470 |
" |
|
1471 |
1.0 exponent |
|
1472 |
1.0 mantissa |
|
1473 |
||
1474 |
0.25 exponent |
|
1475 |
0.25 mantissa |
|
1476 |
||
1477 |
0.00000011111 exponent |
|
1478 |
0.00000011111 mantissa |
|
1479 |
" |
|
1480 |
! ! |
|
1481 |
||
701 | 1482 |
!Float methodsFor:'testing'! |
1483 |
||
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1484 |
isFinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1485 |
"return true, if the receiver is a finite float |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1486 |
i.e. not NaN and not infinite." |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1487 |
|
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1488 |
%{ /* NOCONTEXT */ |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1489 |
|
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1490 |
double dV = __floatVal(self); |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1491 |
|
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1492 |
/* |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1493 |
* notice: on machines which do not provide |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1494 |
* a finite() macro or function (WIN32), |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1495 |
* this may always ret true here ... |
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1496 |
*/ |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1497 |
if (finite(dV)) { |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1498 |
RETURN (true); |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1499 |
} |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1500 |
%}. |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1501 |
^false |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1502 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1503 |
" |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1504 |
1.0 isFinite |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1505 |
(0.0 uncheckedDivide: 0.0) isFinite |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1506 |
(1.0 uncheckedDivide: 0.0) isFinite |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1507 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1508 |
! |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1509 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1510 |
isInfinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1511 |
"return true, if the receiver is an infinite float (Inf). |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1512 |
These are not created by ST/X float operations (they raise an exception); |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1513 |
however, inline C-code could produce them ... |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1514 |
Redefined here for speed" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1515 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1516 |
%{ /* NOCONTEXT */ |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1517 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1518 |
double dV = __floatVal(self); |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1519 |
|
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1520 |
/* |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1521 |
* notice: on machines which do not provide |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1522 |
* finite() & isnan() macros or functions (WIN32), |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1523 |
* this may always ret false here ... |
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1524 |
*/ |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1525 |
#if defined(isinf) || defined(LINUX) |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1526 |
if (isinf(dV)) { RETURN (true); } |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1527 |
#else |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1528 |
if (!finite(dV) && !isnan(dV)) { RETURN (true); } |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1529 |
#endif |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1530 |
%}. |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1531 |
^ false |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1532 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1533 |
" |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1534 |
1.0 isInfinite |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1535 |
(0.0 uncheckedDivide: 0.0) isInfinite |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1536 |
(1.0 uncheckedDivide: 0.0) isInfinite |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1537 |
" |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1538 |
! |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1539 |
|
2387 | 1540 |
isNaN |
1541 |
"return true, if the receiver is an invalid float (NaN - not a number). |
|
1542 |
These are not created by ST/X float operations (they raise an exception); |
|
1543 |
however, inline C-code could produce them ..." |
|
1544 |
||
1545 |
%{ /* NOCONTEXT */ |
|
1546 |
||
3139 | 1547 |
double dV = (__floatVal(self)); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1548 |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1549 |
if (isnan(dV)) { RETURN (true); } |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1550 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1551 |
#if 0 /* Currently all our systems support isnan() |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1552 |
* If not, you have to fix librun/jinterpret.c also. |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1553 |
*/ |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1554 |
|
2395 | 1555 |
/* |
1556 |
* sigh - every vendor is playing its own game here ... |
|
1557 |
* Q: what are standards worth, anyway ? |
|
1558 |
*/ |
|
2392 | 1559 |
#ifdef IS_NAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1560 |
if (IS_NAN(dV)) { RETURN (true); } |
3139 | 1561 |
RETURN (false); |
2393 | 1562 |
#endif |
3139 | 1563 |
|
2393 | 1564 |
#ifdef IS_QNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1565 |
if (IS_QNAN(dV)) { RETURN (true); } |
3139 | 1566 |
RETURN (false); |
2393 | 1567 |
#endif |
2392 | 1568 |
|
2393 | 1569 |
#ifdef FLT_SNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1570 |
if (dV == FLT_SNAN) { RETURN (true); } |
3139 | 1571 |
RETURN (false); |
2393 | 1572 |
#endif |
3139 | 1573 |
|
2393 | 1574 |
#ifdef FLT_QNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1575 |
if (dV == FLT_QNAN) { RETURN (true); } |
3139 | 1576 |
RETURN (false); |
2393 | 1577 |
#endif |
1578 |
||
1579 |
#ifdef _SNANF |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1580 |
if (dV == _SNAN) { RETURN (true); } |
3139 | 1581 |
RETURN (false); |
2393 | 1582 |
#endif |
3139 | 1583 |
|
2393 | 1584 |
#ifdef _QNANF |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1585 |
if (dV == _QNAN) { RETURN (true); } |
3139 | 1586 |
RETURN (false); |
2393 | 1587 |
#endif |
2392 | 1588 |
|
2395 | 1589 |
#ifdef IsPosNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1590 |
if IsPosNAN(dV) { RETURN (true); } |
3139 | 1591 |
RETURN (false); |
2395 | 1592 |
#endif |
3139 | 1593 |
|
2395 | 1594 |
#ifdef IsNegNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1595 |
if IsNegNAN(dV) { RETURN (true); } |
3139 | 1596 |
RETURN (false); |
2395 | 1597 |
#endif |
1598 |
||
2393 | 1599 |
#ifdef NAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1600 |
if (dV == NAN) { RETURN (true); } |
3139 | 1601 |
RETURN (false); |
2390 | 1602 |
#endif |
3139 | 1603 |
|
2399 | 1604 |
#ifdef NaN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1605 |
if (NaN(dV)) { RETURN (true); } |
3139 | 1606 |
RETURN (false); |
2399 | 1607 |
#endif |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1608 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1609 |
#endif /* 0 */ |
2392 | 1610 |
%}. |
1611 |
^ false |
|
3139 | 1612 |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1613 |
" |
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1614 |
1.0 isNaN |
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1615 |
(0.0 uncheckedDivide: 0.0) isNaN |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1616 |
" |
2387 | 1617 |
! |
1618 |
||
701 | 1619 |
negative |
1620 |
"return true if the receiver is less than zero" |
|
1621 |
||
1622 |
%{ /* NOCONTEXT */ |
|
1623 |
||
1133 | 1624 |
RETURN ( (__floatVal(self) < 0.0) ? true : false ); |
701 | 1625 |
%} |
1626 |
! |
|
1627 |
||
1628 |
positive |
|
1629 |
"return true if the receiver is greater or equal to zero" |
|
1630 |
||
1631 |
%{ /* NOCONTEXT */ |
|
1632 |
||
1133 | 1633 |
RETURN ( (__floatVal(self) >= 0.0) ? true : false ); |
701 | 1634 |
%} |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1635 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1636 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1637 |
strictlyPositive |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1638 |
"return true if the receiver is greater than zero" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1639 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1640 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1641 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1642 |
RETURN ( (__floatVal(self) > 0.0) ? true : false ); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1643 |
%} |
701 | 1644 |
! ! |
1645 |
||
1646 |
!Float methodsFor:'truncation and rounding'! |
|
1647 |
||
1648 |
ceiling |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1649 |
"return the smallest integer which is greater or equal to the receiver." |
701 | 1650 |
|
1651 |
|val| |
|
1652 |
||
1653 |
%{ |
|
1654 |
double dVal; |
|
1655 |
||
1656 |
/* |
|
1657 |
* ST-80 (and X3J20) returns integer. |
|
1658 |
*/ |
|
1133 | 1659 |
dVal = ceil(__floatVal(self)); |
701 | 1660 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1661 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1662 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1663 |
__qMKFLOAT(val, dVal); |
701 | 1664 |
%}. |
1665 |
^ val asInteger |
|
1666 |
! |
|
1667 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1668 |
ceilingAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1669 |
"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
|
1670 |
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
|
1671 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1672 |
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
|
1673 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1674 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1675 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1676 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1677 |
OBJ val; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1678 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1679 |
/* |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1680 |
* ST-80 (and X3J20) returns integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1681 |
*/ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1682 |
dVal = ceil(__floatVal(self)); |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1683 |
__qMKFLOAT(val, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1684 |
RETURN (val); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1685 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1686 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1687 |
|
701 | 1688 |
floor |
1689 |
"return the integer nearest the receiver towards negative infinity." |
|
1690 |
||
1691 |
|val| |
|
1692 |
||
1693 |
%{ |
|
1694 |
double dVal; |
|
1695 |
||
1696 |
/* |
|
1697 |
* ST-80 (and X3J20) returns integer. |
|
1698 |
*/ |
|
1133 | 1699 |
dVal = floor(__floatVal(self)); |
701 | 1700 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1701 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1702 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1703 |
__qMKFLOAT(val, dVal); |
701 | 1704 |
%}. |
1705 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1706 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1707 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1708 |
0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1709 |
0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1710 |
-0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1711 |
-0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1712 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1713 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1714 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1715 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1716 |
floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1717 |
"return the integer nearest the receiver towards negative infinity |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1718 |
as a float. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1719 |
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
|
1720 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1721 |
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
|
1722 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1723 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1724 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1725 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1726 |
OBJ v; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1727 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1728 |
dVal = floor(__floatVal(self)); |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1729 |
__qMKFLOAT(v, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1730 |
RETURN (v); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1731 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1732 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1733 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1734 |
0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1735 |
0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1736 |
-0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1737 |
-0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1738 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1739 |
|
701 | 1740 |
! |
1741 |
||
3896 | 1742 |
fractionPart |
1743 |
"extract the after-decimal fraction part. |
|
1744 |
the floats value is |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1745 |
float truncated + float fractionalPart" |
3896 | 1746 |
|
1747 |
%{ /* NOCONTEXT */ |
|
1748 |
||
1749 |
double modf(); |
|
1750 |
double frac, trunc; |
|
1751 |
||
1752 |
errno = 0; |
|
1753 |
frac = modf(__floatVal(self), &trunc); |
|
1754 |
if (errno == 0) { |
|
4305
e71100d13b67
void possible return warning
Claus Gittinger <cg@exept.de>
parents:
4296
diff
changeset
|
1755 |
RETURN (__MKFLOAT(frac)); |
3896 | 1756 |
} |
1757 |
%}. |
|
1758 |
^ self primitiveFailed |
|
1759 |
||
1760 |
" |
|
1761 |
1.0 fractionPart |
|
1762 |
2.0 fractionPart |
|
1763 |
3.0 fractionPart |
|
1764 |
4.0 fractionPart |
|
1765 |
0.5 fractionPart |
|
1766 |
0.25 fractionPart |
|
1767 |
3.14159 fractionPart |
|
1768 |
12345673.14159 fractionPart |
|
1769 |
123456731231231231.14159 fractionPart |
|
1770 |
||
1771 |
3.14159 fractionPart + 3.14159 truncated |
|
1772 |
||
1773 |
12345673.14159 fractionPart + 12345673.14159 truncated |
|
1774 |
||
1775 |
123456731231231231.14159 fractionPart + 123456731231231231.14159 truncated |
|
1776 |
" |
|
1777 |
! |
|
1778 |
||
701 | 1779 |
rounded |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1780 |
"return the receiver rounded to the nearest integer" |
701 | 1781 |
|
1782 |
|val| |
|
1783 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1784 |
%{ |
701 | 1785 |
double dVal; |
1786 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1787 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1788 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1789 |
dVal = ceil(dVal - 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1790 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1791 |
dVal = floor(dVal + 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1792 |
} |
701 | 1793 |
/* |
1794 |
* ST-80 (and X3J20) returns integer. |
|
1795 |
*/ |
|
1796 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1797 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1798 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1799 |
__qMKFLOAT(val, dVal); |
701 | 1800 |
%}. |
1801 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1802 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1803 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1804 |
0.4 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1805 |
0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1806 |
0.6 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1807 |
-0.4 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1808 |
-0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1809 |
-0.6 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1810 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1811 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1812 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1813 |
roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1814 |
"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
|
1815 |
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
|
1816 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1817 |
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
|
1818 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1819 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1820 |
|val| |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1821 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1822 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1823 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1824 |
OBJ v; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1825 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1826 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1827 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1828 |
dVal = ceil(dVal - 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1829 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1830 |
dVal = floor(dVal + 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1831 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1832 |
__qMKFLOAT(v, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1833 |
RETURN (v); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1834 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1835 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1836 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1837 |
0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1838 |
-0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1839 |
0.5 roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1840 |
-0.5 roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1841 |
" |
701 | 1842 |
! |
1843 |
||
1844 |
truncated |
|
1845 |
"return the receiver truncated towards zero as an integer" |
|
1846 |
||
1847 |
|val| |
|
1848 |
||
1849 |
%{ |
|
1850 |
double dVal; |
|
1851 |
||
1133 | 1852 |
dVal = __floatVal(self); |
701 | 1853 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1854 |
dVal = ceil(dVal); |
701 | 1855 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1856 |
dVal = floor(dVal); |
701 | 1857 |
} |
1858 |
||
1859 |
/* |
|
1860 |
* ST-80 (and X3J20) returns integer. |
|
1861 |
*/ |
|
1862 |
if ((dVal >= (double)_MIN_INT) && (dVal <= (double)_MAX_INT)) { |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1863 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1864 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1865 |
__qMKFLOAT(val, dVal); |
701 | 1866 |
%}. |
1867 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1868 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1869 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1870 |
0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1871 |
-0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1872 |
0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1873 |
-0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1874 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1875 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1876 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1877 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1878 |
truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1879 |
"return the receiver truncated towards zero as a float. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1880 |
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
|
1881 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1882 |
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
|
1883 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1884 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1885 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1886 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1887 |
OBJ v; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1888 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1889 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1890 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1891 |
dVal = ceil(dVal); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1892 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1893 |
dVal = floor(dVal); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1894 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1895 |
__qMKFLOAT(v, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1896 |
RETURN (v); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1897 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1898 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1899 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1900 |
0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1901 |
-0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1902 |
0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1903 |
-0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1904 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1905 |
|
701 | 1906 |
! ! |
1907 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1908 |
!Float class methodsFor:'documentation'! |
701 | 1909 |
|
1910 |
version |
|
4454
16acdd393dd0
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
4387
diff
changeset
|
1911 |
^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.96 1999-07-26 09:07:16 stefan Exp $' |
701 | 1912 |
! ! |
2387 | 1913 |
Float initialize! |