author | Claus Gittinger <cg@exept.de> |
Thu, 29 Jan 1998 14:28:19 +0100 | |
changeset 3244 | 9ba0abc1d217 |
parent 3241 | 259bdd31694b |
child 3279 | 09d2ccf1bed2 |
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 |
*/ |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
94 |
# ifndef finite |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
95 |
# define finite(x) 1 |
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 |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
98 |
# define isnan(x) 0 |
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 |
|
3241 | 102 |
#ifndef NEXT3 |
103 |
# ifndef ceil |
|
104 |
double ceil(); |
|
105 |
double floor(); |
|
106 |
# endif |
|
107 |
#endif |
|
108 |
||
701 | 109 |
%} |
110 |
! ! |
|
111 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
112 |
!Float class methodsFor:'documentation'! |
68 | 113 |
|
88 | 114 |
copyright |
115 |
" |
|
116 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
175 | 117 |
All Rights Reserved |
88 | 118 |
|
119 |
This software is furnished under a license and may be used |
|
120 |
only in accordance with the terms of that license and with the |
|
121 |
inclusion of the above copyright notice. This software may not |
|
122 |
be provided or otherwise made available to, or used by, any |
|
123 |
other person. No title to or ownership of the software is |
|
124 |
hereby transferred. |
|
125 |
" |
|
126 |
! |
|
127 |
||
68 | 128 |
documentation |
129 |
" |
|
130 |
Floats represent rational numbers with limited precision. In ST/X, Float uses |
|
131 |
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
|
132 |
are usually represented by the 8-byte IEEE double precision float format. |
68 | 133 |
(but there is no guaranty). |
1 | 134 |
|
68 | 135 |
Notice, that Floats are defined as Byte-array to prevent the garbage collector |
136 |
from going into the value ... otherwise I needed a special case in many places. |
|
137 |
||
138 |
Also notice, that ST/X Floats are what Doubles are in ST-80 - this may change |
|
139 |
in one of the next versions (at least on machines, which provide different float |
|
140 |
and double types in their C-compiler. |
|
141 |
||
142 |
WARNING: |
|
143 |
The layout of float instances is known by the runtime system and the compiler; |
|
144 |
you may not add instance variables here. |
|
369 | 145 |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
146 |
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
|
147 |
of arithmetic operations (even if the operands are subclass-instances). |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
148 |
(It does the float-check by probing a bit in the classes flag instVar). |
85 | 149 |
|
1892 | 150 |
Mixed mode arithmetic: |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
151 |
float op float -> float |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
152 |
float op fix -> float |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
153 |
float op integer -> float |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
154 |
float op float -> float |
1892 | 155 |
|
1295 | 156 |
[Class Variables:] |
85 | 157 |
|
1295 | 158 |
[see also:] |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
159 |
Number |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
160 |
ShortFloat Fraction FixedPoint Integer |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
161 |
FloatArray DoubleArray |
1295 | 162 |
|
163 |
[author:] |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
164 |
Claus Gittinger |
68 | 165 |
" |
2215 | 166 |
! |
167 |
||
168 |
errorHandling |
|
169 |
" |
|
170 |
Floating point error handling and signalling depends on the systems |
|
171 |
(actually: the C-runtime systems) ability to handle floating point errors. |
|
172 |
Most systems report errors by raising an OS floatingPoint exception, |
|
173 |
which is mapped to a fpExceptionInterrupt in ST/X. |
|
174 |
However, some systems do return NaN as result. |
|
175 |
||
176 |
Currently, ST/X does not care specially for these systems - it maybe added |
|
177 |
easily, if there is sufficient customer interest, though. |
|
178 |
||
179 |
Try: |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
180 |
|f1 f2| |
2215 | 181 |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
182 |
f1 := 1.0. |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
183 |
f2 := 0.0. |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
184 |
f1 / f2 |
2215 | 185 |
|
186 |
or: |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
187 |
2 arcSin |
2215 | 188 |
" |
68 | 189 |
! ! |
1 | 190 |
|
2387 | 191 |
!Float class methodsFor:'initialization'! |
192 |
||
193 |
initialize |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
194 |
DefaultPrintFormat := '.6' "/ 6 valid digits |
2387 | 195 |
|
196 |
" |
|
197 |
DefaultPrintFormat := '.9' |
|
198 |
DefaultPrintFormat := '.6' |
|
199 |
" |
|
200 |
! ! |
|
201 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
202 |
!Float class methodsFor:'instance creation'! |
1 | 203 |
|
204 |
basicNew |
|
205 |
"return a new float - here we return 0.0 |
|
206 |
- floats are usually NOT created this way ... |
|
207 |
Its implemented here to allow things like binary store & load |
|
208 |
of floats. (but even this support will go away eventually, its not |
|
209 |
a good idea to store the bits of a float - the reader might have a |
|
13 | 210 |
totally different representation - so floats will eventually be |
211 |
binary stored in a device independent format." |
|
1 | 212 |
|
213 |
%{ /* NOCONTEXT */ |
|
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
214 |
OBJ newFloat; |
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
215 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
216 |
__qMKFLOAT(newFloat, 0.0); |
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
217 |
RETURN (newFloat); |
1 | 218 |
%} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
219 |
! |
1206
9d23c1f5e4d3
use quicker MKFLOAT in FLoat>>basicNew
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
220 |
|
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
221 |
readFrom:aStringOrStream onError:exceptionBlock |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
222 |
"read a float from a string" |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
223 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
224 |
|num| |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
225 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
226 |
num := super readFrom:aStringOrStream onError:nil. |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
227 |
num isNil ifTrue:[ |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
228 |
^ exceptionBlock value |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
229 |
]. |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
230 |
^ num asFloat |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
231 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
232 |
" |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
233 |
Float readFrom:'0.1' |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
234 |
Float readFrom:'0' |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
235 |
" |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
236 |
|
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
237 |
"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
|
238 |
"Modified: / 7.1.1998 / 16:18:33 / cg" |
1 | 239 |
! ! |
240 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
241 |
!Float class methodsFor:'binary storage'! |
701 | 242 |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
243 |
binaryDefinitionFrom:aStream manager: manager |
701 | 244 |
|f| |
245 |
||
246 |
f := self basicNew. |
|
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
247 |
self readBinaryIEEEDoubleFrom:aStream into:f. |
701 | 248 |
^ f |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
249 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
250 |
"Modified: 16.4.1996 / 21:23:38 / cg" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
251 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
252 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
253 |
readBinaryIEEEDoubleFrom:aStream |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
254 |
"read a float from the binary stream, aStream, |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
255 |
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
|
256 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
257 |
|f| |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
258 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
259 |
f := self basicNew. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
260 |
self readBinaryIEEEDoubleFrom:aStream into:f. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
261 |
^ f |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
262 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
263 |
"Created: 16.4.1996 / 20:59:59 / cg" |
701 | 264 |
! |
265 |
||
266 |
readBinaryIEEEDoubleFrom:aStream into:aFloat |
|
267 |
"read the receivers value from the binary stream, aStream, |
|
268 |
interpreting the next bytes as an IEEE formatted 8-byte float" |
|
269 |
||
270 |
" |
|
271 |
this implementation is wrong: does not work on non-IEEE machines |
|
272 |
(to date all machines where ST/X is running on use |
|
273 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
274 |
" |
|
275 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
276 |
"swap the bytes" |
|
277 |
8 to:1 by:-1 do:[:i | |
|
278 |
aFloat basicAt:i put:(aStream next) |
|
279 |
]. |
|
280 |
^ self |
|
281 |
]. |
|
282 |
1 to:8 do:[:i | |
|
283 |
aFloat basicAt:i put:aStream next |
|
284 |
] |
|
285 |
! |
|
286 |
||
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
287 |
readBinaryIEEESingleFrom:aStream |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
288 |
"read a float value from the binary stream, aStream, |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
289 |
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
|
290 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
291 |
|f| |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
292 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
293 |
f := self basicNew. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
294 |
self readBinaryIEEESingleFrom:aStream into:f. |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
295 |
^ f |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
296 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
297 |
"Created: 16.4.1996 / 21:00:35 / cg" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
298 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
299 |
|
701 | 300 |
readBinaryIEEESingleFrom:aStream into:aFloat |
301 |
"read a float value from the binary stream, aStream, |
|
302 |
interpreting the next bytes as an IEEE formatted 4-byte float" |
|
303 |
||
304 |
" |
|
305 |
this implementation is wrong: does not work on non-IEEE machines |
|
306 |
(to date all machines where ST/X is running on use |
|
307 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
308 |
" |
|
309 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
310 |
"swap the bytes" |
|
311 |
8 to:4 by:-1 do:[:i | |
|
312 |
aFloat basicAt:i put:(aStream next) |
|
313 |
]. |
|
314 |
^ self |
|
315 |
]. |
|
316 |
1 to:4 do:[:i | |
|
317 |
aFloat basicAt:i put:aStream next |
|
318 |
] |
|
319 |
! |
|
320 |
||
321 |
storeBinaryIEEEDouble:aFloat on:aStream |
|
322 |
"store aFloat as an IEEE formatted 8-byte float |
|
323 |
onto the binary stream, aStream" |
|
324 |
||
325 |
" |
|
326 |
this implementation is wrong: does not work on non-IEEE machines |
|
327 |
(to date all machines where ST/X is running on use |
|
328 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
329 |
" |
|
330 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
331 |
"swap the bytes" |
|
332 |
8 to:1 by:-1 do:[:i | |
|
333 |
aStream nextPut:(aFloat basicAt:i). |
|
334 |
]. |
|
335 |
^ self |
|
336 |
]. |
|
337 |
1 to:8 do:[:i | |
|
338 |
aStream nextPut:(aFloat basicAt:i). |
|
339 |
]. |
|
340 |
! |
|
341 |
||
342 |
storeBinaryIEEESingle:aFloat on:aStream |
|
343 |
"store aFloat as an IEEE formatted 4-byte float |
|
344 |
onto the binary stream, aStream" |
|
345 |
||
346 |
" |
|
347 |
this implementation is wrong: does not work on non-IEEE machines |
|
348 |
(to date all machines where ST/X is running on use |
|
349 |
IEEE float format. Need more here, when porting ST/X to 370's) |
|
350 |
" |
|
351 |
UninterpretedBytes isBigEndian ifFalse:[ |
|
352 |
"swap the bytes" |
|
353 |
8 to:4 by:-1 do:[:i | |
|
354 |
aStream nextPut:(aFloat basicAt:i). |
|
355 |
]. |
|
356 |
^ self |
|
357 |
]. |
|
358 |
1 to:4 do:[:i | |
|
359 |
aStream nextPut:(aFloat basicAt:i). |
|
360 |
] |
|
361 |
! ! |
|
362 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
363 |
!Float class methodsFor:'constants'! |
1 | 364 |
|
701 | 365 |
pi |
1260 | 366 |
"return the constant pi as Float" |
1 | 367 |
|
3244 | 368 |
"/ dont expect this many valid digits on all machines; |
369 |
"/ The actual precision is very CPU specific. |
|
370 |
||
371 |
^ 3.14159265358979323846264338327950288 |
|
1260 | 372 |
|
373 |
"Modified: 23.4.1996 / 09:27:02 / cg" |
|
1 | 374 |
! |
375 |
||
376 |
unity |
|
1260 | 377 |
"return the neutral element for multiplication (1.0) as Float" |
1 | 378 |
|
379 |
^ 1.0 |
|
1260 | 380 |
|
381 |
"Modified: 23.4.1996 / 09:27:09 / cg" |
|
1 | 382 |
! |
383 |
||
701 | 384 |
zero |
1260 | 385 |
"return the neutral element for addition (0.0) as Float" |
1 | 386 |
|
701 | 387 |
^ 0.0 |
1260 | 388 |
|
389 |
"Modified: 23.4.1996 / 09:27:15 / cg" |
|
1 | 390 |
! ! |
391 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
392 |
!Float class methodsFor:'queries'! |
3 | 393 |
|
394 |
isBuiltInClass |
|
1264 | 395 |
"return true if this class is known by the run-time-system. |
396 |
Here, true is returned for myself, false for subclasses." |
|
3 | 397 |
|
398 |
^ self == Float |
|
1264 | 399 |
|
400 |
"Modified: 23.4.1996 / 15:59:04 / cg" |
|
3 | 401 |
! ! |
402 |
||
1 | 403 |
!Float methodsFor:'arithmetic'! |
404 |
||
701 | 405 |
* aNumber |
406 |
"return the product of the receiver and the argument, aNumber" |
|
407 |
||
408 |
%{ /* NOCONTEXT */ |
|
409 |
||
410 |
OBJ newFloat; |
|
411 |
double result; |
|
412 |
||
413 |
if (__isSmallInteger(aNumber)) { |
|
1133 | 414 |
result = __floatVal(self) * (double)(__intVal(aNumber)); |
701 | 415 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
416 |
__qMKFLOAT(newFloat, result); |
701 | 417 |
RETURN ( newFloat ); |
418 |
} |
|
419 |
if (__isFloatLike(aNumber)) { |
|
1133 | 420 |
result = __floatVal(self) * __floatVal(aNumber); |
701 | 421 |
goto retResult; |
422 |
} |
|
423 |
%} |
|
424 |
. |
|
425 |
^ aNumber productFromFloat:self |
|
426 |
! |
|
427 |
||
1 | 428 |
+ aNumber |
429 |
"return the sum of the receiver and the argument, aNumber" |
|
430 |
||
431 |
%{ /* NOCONTEXT */ |
|
13 | 432 |
|
1 | 433 |
OBJ newFloat; |
434 |
double result; |
|
435 |
||
250 | 436 |
if (__isSmallInteger(aNumber)) { |
1133 | 437 |
result = __floatVal(self) + (double)(__intVal(aNumber)); |
1 | 438 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
439 |
__qMKFLOAT(newFloat, result); |
175 | 440 |
RETURN ( newFloat ); |
1 | 441 |
} |
283 | 442 |
if (__isFloatLike(aNumber)) { |
1133 | 443 |
result = __floatVal(self) + __floatVal(aNumber); |
175 | 444 |
goto retResult; |
1 | 445 |
} |
446 |
%} |
|
447 |
. |
|
448 |
^ aNumber sumFromFloat:self |
|
449 |
! |
|
450 |
||
451 |
- aNumber |
|
452 |
"return the difference of the receiver and the argument, aNumber" |
|
453 |
||
454 |
%{ /* NOCONTEXT */ |
|
13 | 455 |
|
1 | 456 |
OBJ newFloat; |
457 |
double result; |
|
458 |
||
250 | 459 |
if (__isSmallInteger(aNumber)) { |
1133 | 460 |
result = __floatVal(self) - (double)(__intVal(aNumber)); |
1 | 461 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
462 |
__qMKFLOAT(newFloat, result); |
175 | 463 |
RETURN ( newFloat ); |
1 | 464 |
} |
283 | 465 |
if (__isFloatLike(aNumber)) { |
1133 | 466 |
result = __floatVal(self) - __floatVal(aNumber); |
175 | 467 |
goto retResult; |
1 | 468 |
} |
469 |
%} |
|
470 |
. |
|
471 |
^ aNumber differenceFromFloat:self |
|
472 |
! |
|
473 |
||
474 |
/ aNumber |
|
475 |
"return the quotient of the receiver and the argument, aNumber" |
|
476 |
||
477 |
%{ /* NOCONTEXT */ |
|
478 |
||
479 |
OBJ newFloat; |
|
480 |
double result, val; |
|
481 |
||
250 | 482 |
if (__isSmallInteger(aNumber)) { |
1133 | 483 |
if (aNumber != __MKSMALLINT(0)) { |
484 |
result = __floatVal(self) / ( (double)__intVal(aNumber)) ; |
|
1 | 485 |
retResult: |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
486 |
__qMKFLOAT(newFloat, result); |
175 | 487 |
RETURN ( newFloat ); |
488 |
} |
|
1 | 489 |
} else { |
305 | 490 |
if (__isFloatLike(aNumber)) { |
1133 | 491 |
val = __floatVal(aNumber); |
175 | 492 |
if (val != 0.0) { |
1133 | 493 |
result = __floatVal(self) / val; |
175 | 494 |
goto retResult; |
495 |
} |
|
496 |
} |
|
1 | 497 |
} |
498 |
%} |
|
499 |
. |
|
500 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
|
142 | 501 |
" |
502 |
No, you shalt not divide by zero |
|
503 |
" |
|
175 | 504 |
^ DivisionByZeroSignal raise. |
1 | 505 |
]. |
506 |
^ aNumber quotientFromFloat:self |
|
507 |
! |
|
508 |
||
509 |
negated |
|
510 |
"return myself negated" |
|
511 |
||
512 |
%{ /* NOCONTEXT */ |
|
13 | 513 |
|
3 | 514 |
OBJ newFloat; |
1133 | 515 |
double rslt = - __floatVal(self); |
3 | 516 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
517 |
__qMKFLOAT(newFloat, rslt); |
3 | 518 |
RETURN ( newFloat ); |
1 | 519 |
%} |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
520 |
! |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
521 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
522 |
uncheckedDivide:aNumber |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
523 |
"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
|
524 |
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
|
525 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
526 |
%{ /* NOCONTEXT */ |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
527 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
528 |
OBJ newFloat; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
529 |
double result, val; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
530 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
531 |
if (__isSmallInteger(aNumber)) { |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
532 |
result = __floatVal(self) / ( (double)__intVal(aNumber)) ; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
533 |
retResult: |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
534 |
__qMKFLOAT(newFloat, result); |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
535 |
RETURN ( newFloat ); |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
536 |
} else if (__isFloatLike(aNumber)) { |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
537 |
val = __floatVal(aNumber); |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
538 |
result = __floatVal(self) / val; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
539 |
goto retResult; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
540 |
} |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
541 |
%} |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
542 |
. |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
543 |
^ aNumber quotientFromFloat:self |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
544 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
545 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
546 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
547 |
0.0 uncheckedDivide:0.0 |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
548 |
1.0 uncheckedDivide:0.0 |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
549 |
" |
1 | 550 |
! ! |
551 |
||
701 | 552 |
!Float methodsFor:'binary storage'! |
553 |
||
554 |
storeBinaryDefinitionOn:stream manager:manager |
|
1260 | 555 |
"store the receiver in a binary format on stream. |
556 |
This is an internal interface for binary storage mechanism." |
|
557 |
||
701 | 558 |
manager putIdOfClass:(self class) on:stream. |
559 |
Float storeBinaryIEEEDouble:self on:stream. |
|
1260 | 560 |
|
561 |
"Modified: 23.4.1996 / 09:29:48 / cg" |
|
701 | 562 |
! ! |
563 |
||
564 |
!Float methodsFor:'coercion and converting'! |
|
1 | 565 |
|
3014 | 566 |
asDouble |
567 |
"ST80 compatibility: return a float with same value - thats me" |
|
568 |
||
569 |
^ self |
|
570 |
! |
|
571 |
||
701 | 572 |
asFloat |
573 |
"return a float with same value - thats me" |
|
574 |
||
575 |
^ self |
|
576 |
! |
|
577 |
||
578 |
asInteger |
|
579 |
"return an integer with same value - might truncate" |
|
580 |
||
1 | 581 |
%{ /* NOCONTEXT */ |
1670 | 582 |
double dVal; |
13 | 583 |
|
1670 | 584 |
dVal = __floatVal(self); |
585 |
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
|
586 |
RETURN ( __MKSMALLINT( (INT)dVal) ); |
701 | 587 |
} |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
588 |
%}. |
701 | 589 |
^ super asInteger |
590 |
||
591 |
"12345.0 asInteger" |
|
592 |
"1e15 asInteger" |
|
1 | 593 |
! |
594 |
||
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
595 |
asShortFloat |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
596 |
"return a shortFloat with same value as receiver" |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
597 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
598 |
%{ /* NOCONTEXT */ |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
599 |
|
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
600 |
OBJ dummy = @global(ShortFloat); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
601 |
OBJ newFloat; |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
602 |
float fVal = (float)__floatVal(self); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
603 |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
604 |
__qMKSFLOAT(newFloat, fVal); |
1198
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
605 |
RETURN ( newFloat ); |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
606 |
%} |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
607 |
! |
284eeba6b719
docu & limited shortFloat support
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
608 |
|
701 | 609 |
coerce:aNumber |
610 |
"return aNumber converted into receivers type" |
|
1 | 611 |
|
701 | 612 |
^ aNumber asFloat |
613 |
! |
|
13 | 614 |
|
701 | 615 |
generality |
616 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
617 |
||
618 |
^ 80 |
|
1 | 619 |
! ! |
620 |
||
621 |
!Float methodsFor:'comparing'! |
|
622 |
||
623 |
< aNumber |
|
624 |
"return true, if the argument is greater" |
|
625 |
||
626 |
%{ /* NOCONTEXT */ |
|
13 | 627 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
628 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
629 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
630 |
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
|
631 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
632 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
633 |
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
|
634 |
} |
1 | 635 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
636 |
%}. |
1 | 637 |
^ aNumber lessFromFloat:self |
638 |
! |
|
639 |
||
640 |
<= aNumber |
|
641 |
"return true, if the argument is greater or equal" |
|
642 |
||
643 |
%{ /* NOCONTEXT */ |
|
13 | 644 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
645 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
646 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
647 |
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
|
648 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
649 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
650 |
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
|
651 |
} |
1 | 652 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
653 |
%}. |
1 | 654 |
^ self retry:#<= coercing:aNumber |
655 |
! |
|
656 |
||
657 |
= aNumber |
|
175 | 658 |
"return true, if the arguments value are equal by value" |
1 | 659 |
|
660 |
%{ /* NOCONTEXT */ |
|
13 | 661 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
662 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
663 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
664 |
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
|
665 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
666 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
667 |
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
|
668 |
} |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
669 |
} else { |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
670 |
RETURN (false); |
1 | 671 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
672 |
%}. |
1 | 673 |
^ self retry:#= coercing:aNumber |
674 |
! |
|
675 |
||
701 | 676 |
> aNumber |
677 |
"return true, if the argument is less" |
|
1 | 678 |
|
679 |
%{ /* NOCONTEXT */ |
|
13 | 680 |
|
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
681 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
682 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
683 |
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
|
684 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
685 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
686 |
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
|
687 |
} |
1 | 688 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
689 |
%}. |
701 | 690 |
^ self retry:#> coercing:aNumber |
691 |
! |
|
692 |
||
693 |
>= aNumber |
|
694 |
"return true, if the argument is less or equal" |
|
695 |
||
696 |
%{ /* NOCONTEXT */ |
|
697 |
||
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
698 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
699 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
700 |
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
|
701 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
702 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
703 |
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
|
704 |
} |
701 | 705 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
706 |
%}. |
701 | 707 |
^ self retry:#>= coercing:aNumber |
92 | 708 |
! |
709 |
||
710 |
hash |
|
711 |
"return a number for hashing; redefined, since floats compare |
|
712 |
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same |
|
713 |
as 3 hash." |
|
714 |
||
305 | 715 |
|i| |
92 | 716 |
|
717 |
(self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[ |
|
175 | 718 |
i := self asInteger. |
719 |
self = i ifTrue:[ |
|
720 |
^ i hash |
|
721 |
]. |
|
92 | 722 |
]. |
723 |
||
724 |
" |
|
305 | 725 |
mhmh take some of my value-bits to hash on |
92 | 726 |
" |
305 | 727 |
^ (((self basicAt:8) bitAnd:16r3F) bitShift:24) + |
728 |
((self basicAt:7) bitShift:16) + |
|
729 |
((self basicAt:6) bitShift:8) + |
|
730 |
(self basicAt:5) |
|
92 | 731 |
|
732 |
" |
|
733 |
3 hash |
|
734 |
3.0 hash |
|
735 |
3.1 hash |
|
736 |
3.14159 hash |
|
737 |
31.4159 hash |
|
738 |
3.141591 hash |
|
739 |
1.234567890123456 hash |
|
740 |
1.234567890123457 hash |
|
741 |
Set withAll:#(3 3.0 99 99.0 3.1415) |
|
742 |
" |
|
1 | 743 |
! |
744 |
||
701 | 745 |
~= aNumber |
746 |
"return true, if the arguments value are not equal" |
|
1 | 747 |
|
748 |
%{ /* NOCONTEXT */ |
|
749 |
||
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
750 |
if (aNumber != nil) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
751 |
if (__isSmallInteger(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
752 |
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
|
753 |
} |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
754 |
if (__qIsFloatLike(aNumber)) { |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
755 |
RETURN ( (__floatVal(self) != __floatVal(aNumber)) ? true : false ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
756 |
} |
3115
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
757 |
} else { |
1ecfb9118163
dont check twice for nil (in compare ops)
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
758 |
RETURN (true); |
1 | 759 |
} |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
760 |
%}. |
701 | 761 |
^ self retry:#~= coercing:aNumber |
1 | 762 |
! ! |
763 |
||
764 |
!Float methodsFor:'mathematical functions'! |
|
765 |
||
701 | 766 |
arcCos |
767 |
"return the arccosine of myself as radians" |
|
768 |
||
769 |
%{ /* NOCONTEXT */ |
|
770 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
771 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
772 |
OBJ newFloat; |
701 | 773 |
|
774 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
775 |
rslt = acos(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
776 |
if (errno == 0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
777 |
__qMKFLOAT(newFloat, rslt); |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
778 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
779 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
780 |
%}. |
701 | 781 |
^ DomainErrorSignal raise |
782 |
! |
|
783 |
||
784 |
arcSin |
|
785 |
"return the arcsine of myself as radians" |
|
786 |
||
787 |
%{ /* NOCONTEXT */ |
|
788 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
789 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
790 |
OBJ newFloat; |
701 | 791 |
|
792 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
793 |
rslt = asin(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
794 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
795 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
796 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
797 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
798 |
%}. |
701 | 799 |
^ DomainErrorSignal raise |
800 |
! |
|
801 |
||
802 |
arcTan |
|
803 |
"return the arctangent of myself as radians" |
|
804 |
||
805 |
%{ /* NOCONTEXT */ |
|
806 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
807 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
808 |
OBJ newFloat; |
701 | 809 |
|
810 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
811 |
rslt = atan(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
812 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
813 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
814 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
815 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
816 |
%}. |
701 | 817 |
^ DomainErrorSignal raise |
818 |
! |
|
819 |
||
820 |
cos |
|
821 |
"return the cosine of myself interpreted as radians" |
|
822 |
||
823 |
%{ /* NOCONTEXT */ |
|
824 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
825 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
826 |
OBJ newFloat; |
701 | 827 |
|
828 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
829 |
rslt = cos(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
830 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
831 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
832 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
833 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
834 |
%}. |
701 | 835 |
^ DomainErrorSignal raise |
836 |
! |
|
837 |
||
838 |
exp |
|
839 |
"return e raised to the power of the receiver" |
|
840 |
||
841 |
%{ /* NOCONTEXT */ |
|
842 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
843 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
844 |
OBJ newFloat; |
701 | 845 |
|
846 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
847 |
rslt = exp(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
848 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
849 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
850 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
851 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
852 |
%}. |
701 | 853 |
^ DomainErrorSignal raise |
854 |
! |
|
855 |
||
1 | 856 |
ln |
857 |
"return the natural logarithm of myself" |
|
858 |
||
859 |
%{ /* NOCONTEXT */ |
|
860 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
861 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
862 |
OBJ newFloat; |
1 | 863 |
|
864 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
865 |
rslt = log(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
866 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
867 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
868 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
869 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
870 |
%}. |
142 | 871 |
" |
872 |
an invalid value for logarithm |
|
873 |
" |
|
131 | 874 |
^ DomainErrorSignal raise |
1 | 875 |
! |
876 |
||
877 |
raisedTo:aNumber |
|
878 |
"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
|
879 |
|
1 | 880 |
|n| |
881 |
||
882 |
n := aNumber asFloat. |
|
883 |
%{ |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
884 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
885 |
OBJ newFloat; |
1 | 886 |
|
283 | 887 |
if (__isFloatLike(n)) { |
175 | 888 |
errno = 0; |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
889 |
rslt = pow(__floatVal(self), __floatVal(n)); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
890 |
#if 0 |
175 | 891 |
errno = 0; /* XXXX */ |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
892 |
#endif |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
893 |
if (errno == 0) { |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
894 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
895 |
RETURN ( newFloat ); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
896 |
} |
1 | 897 |
} |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
898 |
%}. |
142 | 899 |
" |
900 |
an invalid argument (not convertable to float ?) |
|
901 |
" |
|
131 | 902 |
^ DomainErrorSignal raise |
1 | 903 |
! |
904 |
||
905 |
sin |
|
906 |
"return the sine of myself interpreted as radians" |
|
907 |
||
908 |
%{ /* NOCONTEXT */ |
|
909 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
910 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
911 |
OBJ newFloat; |
1 | 912 |
|
913 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
914 |
rslt = sin(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
915 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
916 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
917 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
918 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
919 |
%}. |
131 | 920 |
^ DomainErrorSignal raise |
1 | 921 |
! |
922 |
||
923 |
sqrt |
|
924 |
"return the square root of myself" |
|
925 |
||
926 |
%{ /* NOCONTEXT */ |
|
927 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
928 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
929 |
OBJ newFloat; |
1 | 930 |
|
931 |
errno = 0; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
932 |
rslt = sqrt(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
933 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
934 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
935 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
936 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
937 |
%}. |
131 | 938 |
^ DomainErrorSignal raise |
701 | 939 |
! |
258 | 940 |
|
701 | 941 |
tan |
942 |
"return the tangent of myself interpreted as radians" |
|
258 | 943 |
|
944 |
%{ /* NOCONTEXT */ |
|
945 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
946 |
double rslt; |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
947 |
OBJ newFloat; |
44 | 948 |
|
701 | 949 |
errno = 0; |
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
950 |
rslt = tan(__floatVal(self)); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
951 |
if (errno == 0) { |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
952 |
__qMKFLOAT(newFloat, rslt); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
953 |
RETURN ( newFloat ); |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
954 |
} |
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
955 |
%}. |
701 | 956 |
^ DomainErrorSignal raise |
13 | 957 |
! ! |
958 |
||
92 | 959 |
!Float methodsFor:'printing & storing'! |
1 | 960 |
|
961 |
printString |
|
2358 | 962 |
"return a printed representation of the receiver; |
963 |
if not specified otherwise (by setting DefaultPrintFormat), |
|
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3163
diff
changeset
|
964 |
6 valid digits are printed. |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3163
diff
changeset
|
965 |
LimitedPrecisonReal and its subclasses use #printString instead of |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3163
diff
changeset
|
966 |
#printOn: as basic print mechanism." |
1 | 967 |
|
968 |
%{ /* NOCONTEXT */ |
|
969 |
||
13 | 970 |
char buffer[64]; |
1 | 971 |
REGISTER char *cp; |
314 | 972 |
OBJ s; |
2358 | 973 |
char *fmt; |
974 |
char fmtBuffer[20]; |
|
975 |
||
976 |
if (__isString(@global(DefaultPrintFormat))) { |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
977 |
fmt = (char *) __stringVal(@global(DefaultPrintFormat)); |
2358 | 978 |
} else { |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
979 |
/* |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
980 |
* in case we get called before #initialize ... |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
981 |
*/ |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
982 |
fmt = ".6"; |
2358 | 983 |
} |
984 |
||
985 |
/* |
|
986 |
* build a printf format string |
|
987 |
*/ |
|
988 |
fmtBuffer[0] = '%'; |
|
989 |
strncpy(fmtBuffer+1, fmt, 10); |
|
990 |
#ifdef SYSV |
|
991 |
strcat(fmtBuffer, "lg"); |
|
992 |
#else |
|
993 |
strcat(fmtBuffer, "G"); |
|
994 |
#endif |
|
314 | 995 |
|
2358 | 996 |
sprintf(buffer, fmtBuffer, __floatVal(self)); |
1 | 997 |
|
998 |
/* |
|
13 | 999 |
* kludge to make integral float f prints as "f.0" (not as "f" as printf does) |
1 | 1000 |
* (i.e. look if string contains '.' or 'e' and append '.0' if not) |
1001 |
*/ |
|
1002 |
for (cp = buffer; *cp; cp++) { |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1003 |
if ((*cp == '.') || (*cp == 'e')) break; |
1 | 1004 |
} |
1005 |
if (! *cp) { |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1006 |
*cp++ = '.'; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1007 |
*cp++ = '0'; |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1008 |
*cp = '\0'; |
1 | 1009 |
} |
1010 |
||
1133 | 1011 |
s = __MKSTRING(buffer COMMA_SND); |
314 | 1012 |
if (s != nil) { |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1013 |
RETURN (s); |
314 | 1014 |
} |
1015 |
%}. |
|
1016 |
" |
|
1017 |
memory allocation (for the new string) failed. |
|
1018 |
When we arrive here, there was no memory, even after a garbage collect. |
|
1019 |
This means, that the VM wanted to get some more memory from the |
|
1020 |
OS, which was not kind enough to give it. |
|
1021 |
Bad luck - you should increase the swap space on your machine. |
|
1022 |
" |
|
1023 |
^ ObjectMemory allocationFailureSignal raise. |
|
1024 |
||
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1025 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1026 |
1.0 printString |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1027 |
1.234 printString |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1028 |
1e10 printString |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1029 |
1.2e3 printString |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1030 |
1.2e30 printString |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1031 |
(1.0 uncheckedDivide:0) printString |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1032 |
(0.0 uncheckedDivide:0) printString |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1033 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1034 |
|
1 | 1035 |
! |
1036 |
||
1037 |
printfPrintString:formatString |
|
1038 |
"non-portable: return a printed representation of the receiver |
|
1039 |
as specified by formatString, which is defined by printf. |
|
31 | 1040 |
If you use this, be aware, that specifying doubles differs on |
1 | 1041 |
systems; on SYSV machines you have to give something like %lf, |
13 | 1042 |
while on BSD systems the format string has to be %F. |
31 | 1043 |
Also, the resulting string may not be longer than 255 bytes - |
54 | 1044 |
since thats the (static) size of the buffer. |
1045 |
This method is NONSTANDARD and may be removed without notice." |
|
1 | 1046 |
|
13 | 1047 |
%{ /* STACK: 400 */ |
1 | 1048 |
char buffer[256]; |
314 | 1049 |
OBJ s; |
1 | 1050 |
|
54 | 1051 |
if (__isString(formatString)) { |
1133 | 1052 |
sprintf(buffer, __stringVal(formatString), __floatVal(self)); |
369 | 1053 |
|
1133 | 1054 |
s = __MKSTRING(buffer COMMA_SND); |
343 | 1055 |
if (s != nil) { |
1056 |
RETURN (s); |
|
1057 |
} |
|
1 | 1058 |
} |
314 | 1059 |
%}. |
1 | 1060 |
self primitiveFailed |
1061 |
||
1062 |
"Float pi printfPrintString:'%%lg -> %lg'" |
|
1063 |
"Float pi printfPrintString:'%%lf -> %lf'" |
|
1064 |
"Float pi printfPrintString:'%%7.5lg -> %7.5lg'" |
|
1065 |
"Float pi printfPrintString:'%%7.5lf -> %7.5lf'" |
|
1066 |
"Float pi printfPrintString:'%%G -> %G'" |
|
1067 |
"Float pi printfPrintString:'%%F -> %F'" |
|
1068 |
"Float pi printfPrintString:'%%7.5G -> %7.5G'" |
|
1069 |
"Float pi printfPrintString:'%%7.5F -> %7.5F'" |
|
1070 |
! ! |
|
701 | 1071 |
|
1072 |
!Float methodsFor:'private accessing'! |
|
1073 |
||
1074 |
basicAt:index |
|
1075 |
"return an internal byte of the float. |
|
1076 |
The value returned here depends on byte order, float representation etc. |
|
1077 |
Therefore, this method should be used strictly private. |
|
1078 |
||
1079 |
Notice: |
|
1080 |
the need to redefine this method here is due to the |
|
1081 |
inability of many machines to store floats in non-double aligned memory. |
|
1082 |
Therefore, on some machines, the first 4 bytes of a float are left unused, |
|
1083 |
and the actual float is stored at index 5 .. 12. |
|
1084 |
To hide this at one place, this method knows about that, and returns |
|
1085 |
values as if this filler wasnt present." |
|
1086 |
||
1087 |
%{ /* NOCONTEXT */ |
|
1088 |
||
1089 |
register int indx; |
|
1090 |
unsigned char *cp; |
|
1091 |
||
1092 |
/* |
|
1093 |
* notice the missing test for self being a nonNilObject - |
|
1094 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
1095 |
* and SmallInteger |
|
1096 |
*/ |
|
1097 |
if (__isSmallInteger(index)) { |
|
1133 | 1098 |
indx = __intVal(index) - 1; |
701 | 1099 |
if ((indx >= 0) && (indx < sizeof(double))) { |
1133 | 1100 |
cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue)); |
1101 |
RETURN ( __MKSMALLINT(cp[indx] & 0xFF) ); |
|
701 | 1102 |
} |
1103 |
} |
|
1104 |
%}. |
|
1105 |
index isInteger ifFalse:[ |
|
1106 |
^ self indexNotInteger |
|
1107 |
]. |
|
1108 |
^ self subscriptBoundsError:index |
|
1109 |
! |
|
1110 |
||
1111 |
basicAt:index put:value |
|
1112 |
"set an internal byte of the float. |
|
1113 |
The value to be stored here depends on byte order, float representation etc. |
|
1114 |
Therefore, this method should be used strictly private. |
|
1115 |
||
1116 |
Notice: |
|
1117 |
the need to redefine this method here is due to the |
|
1118 |
inability of many machines to store floats in non-double aligned memory. |
|
1119 |
Therefore, on some machines, the first 4 bytes of a float are left unused, |
|
1120 |
and the actual float is stored at index 5 .. 12. |
|
1121 |
To hide this at one place, this method knows about that, and returns |
|
1122 |
values as if this filler wasnt present." |
|
1123 |
||
1124 |
%{ /* NOCONTEXT */ |
|
1125 |
register int indx, val; |
|
1126 |
unsigned char *cp; |
|
1127 |
||
1128 |
/* |
|
1129 |
* notice the missing test for self being a nonNilObject - |
|
1130 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
1131 |
* and SmallInteger |
|
1132 |
*/ |
|
1133 |
if (__bothSmallInteger(index, value)) { |
|
1133 | 1134 |
val = __intVal(value); |
701 | 1135 |
if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
1133 | 1136 |
indx = __intVal(index) - 1; |
701 | 1137 |
if ((indx >= 0) && (indx < sizeof(double))) { |
1133 | 1138 |
cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue)); |
701 | 1139 |
cp[indx] = val; |
1140 |
RETURN ( value ); |
|
1141 |
} |
|
1142 |
} |
|
1143 |
} |
|
1144 |
%}. |
|
1145 |
index isInteger ifFalse:[ |
|
1146 |
^ self indexNotInteger |
|
1147 |
]. |
|
1148 |
value isInteger ifFalse:[ |
|
1149 |
" |
|
1150 |
the object to store should be an integer number |
|
1151 |
" |
|
1152 |
^ self elementNotInteger |
|
1153 |
]. |
|
1154 |
(value between:0 and:255) ifFalse:[ |
|
1155 |
" |
|
1156 |
the object to store must be a bytes value |
|
1157 |
" |
|
1158 |
^ self elementBoundsError |
|
1159 |
]. |
|
1160 |
^ self subscriptBoundsError:index |
|
1161 |
! ! |
|
1162 |
||
1163 |
!Float methodsFor:'testing'! |
|
1164 |
||
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1165 |
isFinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1166 |
"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
|
1167 |
i.e. not NaN and not infinite." |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1168 |
|
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1169 |
%{ /* NOCONTEXT */ |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1170 |
|
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1171 |
double dV = __floatVal(self); |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1172 |
|
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1173 |
/* |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1174 |
* 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
|
1175 |
* a finite() macro or function (WIN32), |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1176 |
* this may always return true here ... |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1177 |
*/ |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1178 |
if (finite(dV)) { |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1179 |
RETURN (true); |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1180 |
} |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1181 |
%}. |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1182 |
^false |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1183 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1184 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1185 |
1.0 isFinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1186 |
(0.0 uncheckedDivide: 0.0) isFinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1187 |
(1.0 uncheckedDivide: 0.0) isFinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1188 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1189 |
! |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1190 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1191 |
isInfinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1192 |
"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
|
1193 |
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
|
1194 |
however, inline C-code could produce them ... |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1195 |
Redefined here for speed" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1196 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1197 |
%{ /* NOCONTEXT */ |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1198 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1199 |
double dV = __floatVal(self); |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1200 |
|
3198
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1201 |
/* |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1202 |
* 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
|
1203 |
* finite() & isnan() macros or functions (WIN32), |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1204 |
* this may always return false here ... |
4f930c1c96e7
care for systems which do not define finite() / isnan() - sigh
Claus Gittinger <cg@exept.de>
parents:
3194
diff
changeset
|
1205 |
*/ |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1206 |
#if defined(isinf) || defined(LINUX) |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1207 |
if (isinf(dV)) { RETURN (true); } |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1208 |
#else |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1209 |
if (!finite(dV) && !isnan(dV)) { RETURN (true); } |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1210 |
#endif |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1211 |
%}. |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1212 |
^ false |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1213 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1214 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1215 |
1.0 isInfinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1216 |
(0.0 uncheckedDivide: 0.0) isInfinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1217 |
(1.0 uncheckedDivide: 0.0) isInfinite |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1218 |
" |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1219 |
! |
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1220 |
|
2387 | 1221 |
isNaN |
1222 |
"return true, if the receiver is an invalid float (NaN - not a number). |
|
1223 |
These are not created by ST/X float operations (they raise an exception); |
|
1224 |
however, inline C-code could produce them ..." |
|
1225 |
||
1226 |
%{ /* NOCONTEXT */ |
|
1227 |
||
3139 | 1228 |
double dV = (__floatVal(self)); |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1229 |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1230 |
if (isnan(dV)) { RETURN (true); } |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1231 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1232 |
#if 0 /* Currently all our systems support isnan() |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1233 |
* 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
|
1234 |
*/ |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1235 |
|
2395 | 1236 |
/* |
1237 |
* sigh - every vendor is playing its own game here ... |
|
1238 |
* Q: what are standards worth, anyway ? |
|
1239 |
*/ |
|
2392 | 1240 |
#ifdef IS_NAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1241 |
if (IS_NAN(dV)) { RETURN (true); } |
3139 | 1242 |
RETURN (false); |
2393 | 1243 |
#endif |
3139 | 1244 |
|
2393 | 1245 |
#ifdef IS_QNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1246 |
if (IS_QNAN(dV)) { RETURN (true); } |
3139 | 1247 |
RETURN (false); |
2393 | 1248 |
#endif |
2392 | 1249 |
|
2393 | 1250 |
#ifdef FLT_SNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1251 |
if (dV == FLT_SNAN) { RETURN (true); } |
3139 | 1252 |
RETURN (false); |
2393 | 1253 |
#endif |
3139 | 1254 |
|
2393 | 1255 |
#ifdef FLT_QNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1256 |
if (dV == FLT_QNAN) { RETURN (true); } |
3139 | 1257 |
RETURN (false); |
2393 | 1258 |
#endif |
1259 |
||
1260 |
#ifdef _SNANF |
|
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1261 |
if (dV == _SNAN) { RETURN (true); } |
3139 | 1262 |
RETURN (false); |
2393 | 1263 |
#endif |
3139 | 1264 |
|
2393 | 1265 |
#ifdef _QNANF |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1266 |
if (dV == _QNAN) { RETURN (true); } |
3139 | 1267 |
RETURN (false); |
2393 | 1268 |
#endif |
2392 | 1269 |
|
2395 | 1270 |
#ifdef IsPosNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1271 |
if IsPosNAN(dV) { RETURN (true); } |
3139 | 1272 |
RETURN (false); |
2395 | 1273 |
#endif |
3139 | 1274 |
|
2395 | 1275 |
#ifdef IsNegNAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1276 |
if IsNegNAN(dV) { RETURN (true); } |
3139 | 1277 |
RETURN (false); |
2395 | 1278 |
#endif |
1279 |
||
2393 | 1280 |
#ifdef NAN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1281 |
if (dV == NAN) { RETURN (true); } |
3139 | 1282 |
RETURN (false); |
2390 | 1283 |
#endif |
3139 | 1284 |
|
2399 | 1285 |
#ifdef NaN |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1286 |
if (NaN(dV)) { RETURN (true); } |
3139 | 1287 |
RETURN (false); |
2399 | 1288 |
#endif |
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1289 |
|
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1290 |
#endif /* 0 */ |
2392 | 1291 |
%}. |
1292 |
^ false |
|
3139 | 1293 |
|
3146
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1294 |
" |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1295 |
1.0 isNaN |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1296 |
(0.0 uncheckedDivide: 0.0) isNaN |
4e46505d1d59
New #finite, fix #isNaN and #isInfinite.
Stefan Vogel <sv@exept.de>
parents:
3139
diff
changeset
|
1297 |
" |
2387 | 1298 |
! |
1299 |
||
701 | 1300 |
negative |
1301 |
"return true if the receiver is less than zero" |
|
1302 |
||
1303 |
%{ /* NOCONTEXT */ |
|
1304 |
||
1133 | 1305 |
RETURN ( (__floatVal(self) < 0.0) ? true : false ); |
701 | 1306 |
%} |
1307 |
! |
|
1308 |
||
1309 |
positive |
|
1310 |
"return true if the receiver is greater or equal to zero" |
|
1311 |
||
1312 |
%{ /* NOCONTEXT */ |
|
1313 |
||
1133 | 1314 |
RETURN ( (__floatVal(self) >= 0.0) ? true : false ); |
701 | 1315 |
%} |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1316 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1317 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1318 |
strictlyPositive |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1319 |
"return true if the receiver is greater than zero" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1320 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1321 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1322 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1323 |
RETURN ( (__floatVal(self) > 0.0) ? true : false ); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1324 |
%} |
701 | 1325 |
! ! |
1326 |
||
1327 |
!Float methodsFor:'truncation and rounding'! |
|
1328 |
||
1329 |
ceiling |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1330 |
"return the smallest integer which is greater or equal to the receiver." |
701 | 1331 |
|
1332 |
|val| |
|
1333 |
||
1334 |
%{ |
|
1335 |
double dVal; |
|
1336 |
||
1337 |
/* |
|
1338 |
* ST-80 (and X3J20) returns integer. |
|
1339 |
*/ |
|
1133 | 1340 |
dVal = ceil(__floatVal(self)); |
701 | 1341 |
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
|
1342 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1343 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1344 |
__qMKFLOAT(val, dVal); |
701 | 1345 |
%}. |
1346 |
^ val asInteger |
|
1347 |
! |
|
1348 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1349 |
ceilingAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1350 |
"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
|
1351 |
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
|
1352 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1353 |
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
|
1354 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1355 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1356 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1357 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1358 |
OBJ val; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1359 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1360 |
/* |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1361 |
* ST-80 (and X3J20) returns integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1362 |
*/ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1363 |
dVal = ceil(__floatVal(self)); |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1364 |
__qMKFLOAT(val, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1365 |
RETURN (val); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1366 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1367 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1368 |
|
701 | 1369 |
floor |
1370 |
"return the integer nearest the receiver towards negative infinity." |
|
1371 |
||
1372 |
|val| |
|
1373 |
||
1374 |
%{ |
|
1375 |
double dVal; |
|
1376 |
||
1377 |
/* |
|
1378 |
* ST-80 (and X3J20) returns integer. |
|
1379 |
*/ |
|
1133 | 1380 |
dVal = floor(__floatVal(self)); |
701 | 1381 |
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
|
1382 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1383 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1384 |
__qMKFLOAT(val, dVal); |
701 | 1385 |
%}. |
1386 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1387 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1388 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1389 |
0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1390 |
0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1391 |
-0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1392 |
-0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1393 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1394 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1395 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1396 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1397 |
floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1398 |
"return the integer nearest the receiver towards negative infinity |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1399 |
as a float. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1400 |
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
|
1401 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1402 |
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
|
1403 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1404 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1405 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1406 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1407 |
OBJ v; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1408 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1409 |
dVal = floor(__floatVal(self)); |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1410 |
__qMKFLOAT(v, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1411 |
RETURN (v); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1412 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1413 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1414 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1415 |
0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1416 |
0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1417 |
-0.5 floor |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1418 |
-0.5 floorAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1419 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1420 |
|
701 | 1421 |
! |
1422 |
||
1423 |
rounded |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1424 |
"return the receiver rounded to the nearest integer" |
701 | 1425 |
|
1426 |
|val| |
|
1427 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1428 |
%{ |
701 | 1429 |
double dVal; |
1430 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1431 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1432 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1433 |
dVal = ceil(dVal - 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1434 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1435 |
dVal = floor(dVal + 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1436 |
} |
701 | 1437 |
/* |
1438 |
* ST-80 (and X3J20) returns integer. |
|
1439 |
*/ |
|
1440 |
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
|
1441 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1442 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1443 |
__qMKFLOAT(val, dVal); |
701 | 1444 |
%}. |
1445 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1446 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1447 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1448 |
0.4 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1449 |
0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1450 |
0.6 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1451 |
-0.4 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1452 |
-0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1453 |
-0.6 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1454 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1455 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1456 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1457 |
roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1458 |
"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
|
1459 |
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
|
1460 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1461 |
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
|
1462 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1463 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1464 |
|val| |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1465 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1466 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1467 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1468 |
OBJ v; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1469 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1470 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1471 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1472 |
dVal = ceil(dVal - 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1473 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1474 |
dVal = floor(dVal + 0.5); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1475 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1476 |
__qMKFLOAT(v, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1477 |
RETURN (v); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1478 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1479 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1480 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1481 |
0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1482 |
-0.5 rounded |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1483 |
0.5 roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1484 |
-0.5 roundedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1485 |
" |
701 | 1486 |
! |
1487 |
||
1488 |
truncated |
|
1489 |
"return the receiver truncated towards zero as an integer" |
|
1490 |
||
1491 |
|val| |
|
1492 |
||
1493 |
%{ |
|
1494 |
double dVal; |
|
1495 |
||
1133 | 1496 |
dVal = __floatVal(self); |
701 | 1497 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1498 |
dVal = ceil(dVal); |
701 | 1499 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1500 |
dVal = floor(dVal); |
701 | 1501 |
} |
1502 |
||
1503 |
/* |
|
1504 |
* ST-80 (and X3J20) returns integer. |
|
1505 |
*/ |
|
1506 |
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
|
1507 |
RETURN ( __MKSMALLINT( (INT) dVal ) ); |
701 | 1508 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1509 |
__qMKFLOAT(val, dVal); |
701 | 1510 |
%}. |
1511 |
^ val asInteger |
|
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1512 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1513 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1514 |
0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1515 |
-0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1516 |
0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1517 |
-0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1518 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1519 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1520 |
! |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1521 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1522 |
truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1523 |
"return the receiver truncated towards zero as a float. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1524 |
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
|
1525 |
of the result to an integer. |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1526 |
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
|
1527 |
float-operation." |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1528 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1529 |
%{ /* NOCONTEXT */ |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1530 |
double dVal; |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1531 |
OBJ v; |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1532 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1533 |
dVal = __floatVal(self); |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1534 |
if (dVal < 0.0) { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1535 |
dVal = ceil(dVal); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1536 |
} else { |
3127
590c7d2bb4b9
fixes isNAN (on linux); added #isInfinite
Claus Gittinger <cg@exept.de>
parents:
3118
diff
changeset
|
1537 |
dVal = floor(dVal); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1538 |
} |
3163
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1539 |
__qMKFLOAT(v, dVal); |
212a539ee379
added #readFrom: to avoid returning an int.
Claus Gittinger <cg@exept.de>
parents:
3146
diff
changeset
|
1540 |
RETURN (v); |
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1541 |
%} |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1542 |
|
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1543 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1544 |
0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1545 |
-0.5 truncated |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1546 |
0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1547 |
-0.5 truncatedAsFloat |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1548 |
" |
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1549 |
|
701 | 1550 |
! ! |
1551 |
||
1879
26df273349c4
added ceilingAsFloat, floorAsFloat, truncatedAsFloat
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
1552 |
!Float class methodsFor:'documentation'! |
701 | 1553 |
|
1554 |
version |
|
3244 | 1555 |
^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.75 1998-01-29 13:28:19 cg Exp $' |
701 | 1556 |
! ! |
2387 | 1557 |
Float initialize! |