189 |
189 |
190 Floats give you 64 bit floats. |
190 Floats give you 64 bit floats. |
191 In contrast to ShortFloats (32bit) and LongFloats (>=64bit). |
191 In contrast to ShortFloats (32bit) and LongFloats (>=64bit). |
192 |
192 |
193 WARNING: |
193 WARNING: |
194 The layout of Float instances is known by the runtime system and the compiler; |
194 The layout of Float instances is known by the runtime system and the compiler; |
195 you may not add instance variables here. |
195 you may not add instance variables here. |
196 Also, subclassing is complicated by the fact, that the VM creates floats/shortFloats, |
196 Also, subclassing is complicated by the fact, that the VM creates floats/shortFloats, |
197 and does some float-checks by an identity compare with the Float-class. |
197 and does some float-checks by an identity compare with the Float-class. |
198 (i.e. your subclasses instances may not be recognized as float-like objects, |
198 (i.e. your subclasses instances may not be recognized as float-like objects, |
199 thus mixed mode arithmetic will always coerce them, effectively slowing things down). |
199 thus mixed mode arithmetic will always coerce them, effectively slowing things down). |
200 |
200 |
201 Notice, that Floats are defined as Byte-array to prevent the garbage collector |
201 Notice, that Floats are defined as Byte-array to prevent the garbage collector |
202 from going into the value ... otherwise I needed a special case in many places. |
202 from going into the value ... otherwise I needed a special case in many places. |
203 |
203 |
204 Also notice, that ST/X Floats are what Doubles are in ST-80 - this may change |
204 Also notice, that ST/X Floats are what Doubles are in ST-80 - this may change |
212 (although some memory is wasted when porting from VW). |
212 (although some memory is wasted when porting from VW). |
213 Notice that ST/X provides an alias called Double, and an extra ShortFloat class, which has 4-byte |
213 Notice that ST/X provides an alias called Double, and an extra ShortFloat class, which has 4-byte |
214 instances. |
214 instances. |
215 |
215 |
216 Mixed mode arithmetic: |
216 Mixed mode arithmetic: |
217 float op float -> float |
217 float op float -> float |
218 float op fix -> float |
218 float op fix -> float |
219 float op fraction -> float |
219 float op fraction -> float |
220 float op integer -> float |
220 float op integer -> float |
221 float op shortFloat -> float |
221 float op shortFloat -> float |
222 float op longFloat -> longFloat |
222 float op longFloat -> longFloat |
223 float op complex -> complex |
223 float op complex -> complex |
224 |
224 |
225 Representation: |
225 Representation: |
226 64bit double precision IEE floats |
226 64bit double precision IEE floats |
227 53 bit mantissa, |
227 53 bit mantissa, |
228 11 bit exponent, |
228 11 bit exponent, |
229 15 decimal digits (approx) |
229 15 decimal digits (approx) |
230 |
230 |
231 Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation |
231 Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation |
232 |
232 |
233 [author:] |
233 [author:] |
234 Claus Gittinger |
234 Claus Gittinger |
235 |
235 |
236 [see also:] |
236 [see also:] |
237 Number |
237 Number |
238 ShortFloat LongFloat Fraction FixedPoint Integer Complex |
238 ShortFloat LongFloat Fraction FixedPoint Integer Complex |
239 FloatArray DoubleArray |
239 FloatArray DoubleArray |
240 " |
240 " |
241 ! |
241 ! |
242 |
242 |
243 errorHandling |
243 errorHandling |
244 " |
244 " |
2440 double val, rslt; |
2440 double val, rslt; |
2441 OBJ newFloat; |
2441 OBJ newFloat; |
2442 |
2442 |
2443 __threadErrno = 0; |
2443 __threadErrno = 0; |
2444 val = __floatVal(self); |
2444 val = __floatVal(self); |
2445 # ifdef WIN32 /* dont know (yet) how to suppress the warnBox opened by win32 */ |
2445 # ifdef WIN32 /* don't know (yet) how to suppress the warnBox opened by win32 */ |
2446 if ((val >= -1.0) && (val <= 1.0)) |
2446 if ((val >= -1.0) && (val <= 1.0)) |
2447 # endif |
2447 # endif |
2448 { |
2448 { |
2449 rslt = atanh(__floatVal(self)); |
2449 rslt = atanh(__floatVal(self)); |
2450 if (! isnan(rslt)) /* Currently all our systems support isnan() */ |
2450 if (! isnan(rslt)) /* Currently all our systems support isnan() */ |
|
2451 #ifdef __osx__ |
|
2452 if (! isinf(rslt)) |
|
2453 #endif |
2451 { |
2454 { |
2452 if (__threadErrno == 0) { |
2455 if (__threadErrno == 0) { |
2453 __qMKFLOAT(newFloat, rslt); |
2456 __qMKFLOAT(newFloat, rslt); |
2454 RETURN ( newFloat ); |
2457 RETURN ( newFloat ); |
2455 } |
2458 } |