--- a/LongFloat.st Thu Oct 30 17:15:01 2003 +0100
+++ b/LongFloat.st Fri Oct 31 12:15:28 2003 +0100
@@ -63,33 +63,33 @@
*/
# ifndef isnanl
# define isnanl(x) \
- ((((unsigned int *)(&x))[0] == 0x00000000) && \
- (((unsigned int *)(&x))[1] == 0xC0000000) && \
- (((unsigned short *)(&x))[4] == 0xFFFF))
+ ((((unsigned int *)(&x))[0] == 0x00000000) && \
+ (((unsigned int *)(&x))[1] == 0xC0000000) && \
+ (((unsigned short *)(&x))[4] == 0xFFFF))
# endif
# ifndef isnan
# define isnan(x) \
- ((((unsigned int *)(&x))[0] == 0x00000000) && \
- (((unsigned int *)(&x))[1] == 0xFFF80000))
+ ((((unsigned int *)(&x))[0] == 0x00000000) && \
+ (((unsigned int *)(&x))[1] == 0xFFF80000))
# endif
# ifndef isPositiveInfinity
# define isPositiveInfinity(x) \
- ((((unsigned int *)(&x))[0] == 0x00000000) && \
- (((unsigned int *)(&x))[1] == 0x7FF00000))
+ ((((unsigned int *)(&x))[0] == 0x00000000) && \
+ (((unsigned int *)(&x))[1] == 0x7FF00000))
# endif
# ifndef isNegativeInfinity
# define isPositiveInfinity(x) \
- ((((unsigned int *)(&x))[0] == 0x00000000) && \
- (((unsigned int *)(&x))[1] == 0xFFF00000))
+ ((((unsigned int *)(&x))[0] == 0x00000000) && \
+ (((unsigned int *)(&x))[1] == 0xFFF00000))
# endif
# ifndef isinf
# define isinf(x) \
- ((((unsigned int *)(&x))[0] == 0x00000000) && \
- ((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000))
+ ((((unsigned int *)(&x))[0] == 0x00000000) && \
+ ((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000))
# endif
# ifndef finite
@@ -110,14 +110,9 @@
# endif
#endif /* realIX */
-#ifdef WIN32
+#if defined(__GNUC__) || defined(WIN32)
# define LONGFLOAT long double
-# define LONG_isnan isnanl
-#endif
-
-#if defined(__GNUC__)
-# define LONGFLOAT long double
-# if defined(linux)
+# if defined(linux) || defined(WIN32)
# define LONG_ceil ceill
# define LONG_floor floorl
# define LONG_sqrt sqrtl
@@ -130,9 +125,6 @@
# define LONG_asin asinl
# define LONG_acos acosl
# define LONG_atan atanl
-# define LONG_asinh asinhl
-# define LONG_acosh acoshl
-# define LONG_atanh atanhl
# define LONG_exp expl
# define LONG_frexp frexpl
# define LONG_log logl
@@ -141,7 +133,13 @@
# define LONG_isnan isnanl
# define LONG_isfinite isfinitel
# endif
-#endif
+# if defined(linux)
+# define LONG_asinh asinhl
+# define LONG_acosh acoshl
+# define LONG_atanh atanhl
+# endif /* defined(lunux) */
+
+#endif /* defined(GCC) || defined(WIN32)
/*
* on systems which do not support long doubles, fall back to Float
@@ -157,38 +155,38 @@
#endif
struct __longfloatstruct {
- HEADER
+ HEADER
#ifdef __NEED_DOUBLE_ALIGN
- __FILLTYPE_DOUBLE f_filler;
+ __FILLTYPE_DOUBLE f_filler;
#endif
- LONGFLOAT f_longfloatvalue;
+ LONGFLOAT f_longfloatvalue;
};
#define __LongFloatInstPtr(obj) ((struct __longfloatstruct *)(__objPtr(obj)))
#ifndef __longFloatVal
# define __longFloatVal(o) \
- __LongFloatInstPtr(o)->f_longfloatvalue
+ __LongFloatInstPtr(o)->f_longfloatvalue
#endif
#ifndef __qMKLFLOAT
# define __qMKLFLOAT(__newFloat__, __fVal__) \
{ \
- __qNew(__newFloat__ , sizeof(struct __longfloatstruct)); \
- if (__newFloat__) { \
- __qClass(__newFloat__) = LONGFLOAT_GLOBAL; \
- __LongFloatInstPtr(__newFloat__)->f_longfloatvalue = (LONGFLOAT)(__fVal__); \
- } \
+ __qNew(__newFloat__ , sizeof(struct __longfloatstruct)); \
+ if (__newFloat__) { \
+ __qClass(__newFloat__) = LONGFLOAT_GLOBAL; \
+ __LongFloatInstPtr(__newFloat__)->f_longfloatvalue = (LONGFLOAT)(__fVal__); \
+ } \
}
#endif
#ifndef __isLongFloat
# define __isLongFloat(o) \
- (__Class(o) == @global(LongFloat))
+ (__Class(o) == @global(LongFloat))
#endif
#ifndef __qIsLongFloat
# define __qIsLongFloat(o) \
- (__qClass(o) == @global(LongFloat))
+ (__qClass(o) == @global(LongFloat))
#endif
%}
@@ -222,46 +220,46 @@
(thus, longFloat code is not quaranteed to be portable).
NO GUARANTY:
- on systems which do not support 'long doubles', LongFloats are (silently)
- represented as 'doubles'.
+ on systems which do not support 'long doubles', LongFloats are (silently)
+ represented as 'doubles'.
Representation:
- gcc-i386:
- 80bit extended IEE floats stored in in 96bits (12bytes);
- 64 bit mantissa,
- 16 bit exponent,
- 19 decimal digits (approx)
+ gcc-i386:
+ 80bit extended IEE floats stored in in 96bits (12bytes);
+ 64 bit mantissa,
+ 16 bit exponent,
+ 19 decimal digits (approx)
- borland-i386 (WIN32):
- 80bit extended IEE floats stored in in 80bits (10bytes);
- 64 bit mantissa,
- 16 bit exponent,
- 19 decimal digits (approx)
+ borland-i386 (WIN32):
+ 80bit extended IEE floats stored in in 80bits (10bytes);
+ 64 bit mantissa,
+ 16 bit exponent,
+ 19 decimal digits (approx)
- gcc-sparc:
- 128bit quad IEE floats (16bytes);
- 112 bit mantissa,
- 16 bit exponent,
- 34 decimal digits (approx)
+ gcc-sparc:
+ 128bit quad IEE floats (16bytes);
+ 112 bit mantissa,
+ 16 bit exponent,
+ 34 decimal digits (approx)
Mixed mode arithmetic:
- longFloat op longFloat -> longFloat
- longFloat op fix -> longFloat
- longFloat op fraction -> longFloat
- longFloat op integer -> longFloat
- longFloat op shortFloat -> longFloat
- longFloat op float -> longFloat
- longFloat op complex -> complex
+ longFloat op longFloat -> longFloat
+ longFloat op fix -> longFloat
+ longFloat op fraction -> longFloat
+ longFloat op integer -> longFloat
+ longFloat op shortFloat -> longFloat
+ longFloat op float -> longFloat
+ longFloat op complex -> complex
Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- Number
- Float ShortFloat Fraction FixedPoint Integer Complex
- FloatArray DoubleArray
+ Number
+ Float ShortFloat Fraction FixedPoint Integer Complex
+ FloatArray DoubleArray
"
! !
@@ -279,9 +277,9 @@
%{ /* NOCONTEXT */
OBJ newFloat;
if (sizeof(LONGFLOAT) == sizeof(double)) {
- __qMKFLOAT(newFloat, 0.0); /* OBJECT ALLOCATION */
+ __qMKFLOAT(newFloat, 0.0); /* OBJECT ALLOCATION */
} else {
- __qMKLFLOAT(newFloat, 0.0); /* OBJECT ALLOCATION */
+ __qMKLFLOAT(newFloat, 0.0); /* OBJECT ALLOCATION */
}
RETURN (newFloat);
%}
@@ -295,13 +293,13 @@
LONGFLOAT f;
if (sizeof(LONGFLOAT) == sizeof(double)) {
- RETURN (aFloat);
+ RETURN (aFloat);
}
if (__isFloatLike(aFloat)) {
- f = (LONGFLOAT)(__floatVal(aFloat));
- __qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */
- RETURN (newFloat);
+ f = (LONGFLOAT)(__floatVal(aFloat));
+ __qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */
+ RETURN (newFloat);
}
%}.
self error:'invalid argumnet'
@@ -321,9 +319,9 @@
LONGFLOAT f;
if (__isSmallInteger(anInteger)) {
- f = (LONGFLOAT)(__smallIntegerVal(anInteger));
- __qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */
- RETURN (newFloat);
+ f = (LONGFLOAT)(__smallIntegerVal(anInteger));
+ __qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */
+ RETURN (newFloat);
}
%}.
^ super fromInteger:anInteger
@@ -343,9 +341,9 @@
LONGFLOAT f;
if (__isShortFloat(aFloat)) {
- f = (LONGFLOAT)(__shortFloatVal(aFloat));
- __qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */
- RETURN (newFloat);
+ f = (LONGFLOAT)(__shortFloatVal(aFloat));
+ __qMKLFLOAT(newFloat, f); /* OBJECT ALLOCATION */
+ RETURN (newFloat);
}
%}.
self error:'invalid argumnet'
@@ -468,23 +466,23 @@
numBitsInExponent
"answer the number of bits in the exponent
i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused),
- where 15 bits are available in the exponent (i bit is ignored):
- 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
+ where 15 bits are available in the exponent (i bit is ignored):
+ 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
"
%{
if (sizeof(LONGFLOAT) == 10) { /* i386 - WIN32 */
- RETURN (__MKSMALLINT(15));
+ RETURN (__MKSMALLINT(15));
}
if (sizeof(LONGFLOAT) == 12) { /* i386 */
- RETURN (__MKSMALLINT(15));
+ RETURN (__MKSMALLINT(15));
}
if (sizeof(LONGFLOAT) == 16) { /* sparc */
- RETURN (__MKSMALLINT(15));
+ RETURN (__MKSMALLINT(15));
}
%}.
"systems without longFloat support use doubles instead"
self basicNew basicSize == Float basicNew basicSize ifTrue:[
- ^ Float numBitsInExponent
+ ^ Float numBitsInExponent
].
self error:'missing definition' "ifdef missing in above primitive code for this architecture"
@@ -496,23 +494,23 @@
numBitsInIntegerPart
"answer the number of bits in the integer part of the mantissa
i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused),
- where 1 bit is used for the integer part in the mantissa:
- 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
+ where 1 bit is used for the integer part in the mantissa:
+ 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
"
%{
if (sizeof(LONGFLOAT) == 10) { /* i386 - WIN32 */
- RETURN (__MKSMALLINT(1));
+ RETURN (__MKSMALLINT(1));
}
if (sizeof(LONGFLOAT) == 12) { /* i386 */
- RETURN (__MKSMALLINT(1));
+ RETURN (__MKSMALLINT(1));
}
if (sizeof(LONGFLOAT) == 16) { /* sparc */
- RETURN (__MKSMALLINT(0));
+ RETURN (__MKSMALLINT(0));
}
%}.
"systems without longFloat support use doubles instead"
self basicNew basicSize == Float basicNew basicSize ifTrue:[
- ^ Float numBitsInIntegerPart
+ ^ Float numBitsInIntegerPart
].
self error:'missing definition' "ifdef missing in above primitive code for this architecture"
@@ -524,26 +522,26 @@
numBitsInMantissa
"answer the number of bits in the mantissa
i386: This is an 80bit longfloat stored in 96 bits (upper 16 bits are unused),
- where 1+63 bits are available in the mantissa:
- 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
+ where 1+63 bits are available in the mantissa:
+ 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
sparc: This is an 128bit longfloat,
- where 1+112 bits are available in the mantissa:
- 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
+ where 1+112 bits are available in the mantissa:
+ 00000000 00000000 seeeeeee eeeeeeee immmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
"
%{
if (sizeof(LONGFLOAT) == 10) { /* i386 - WIN32 */
- RETURN (__MKSMALLINT(64));
+ RETURN (__MKSMALLINT(64));
}
if (sizeof(LONGFLOAT) == 12) { /* i386 */
- RETURN (__MKSMALLINT(64));
+ RETURN (__MKSMALLINT(64));
}
if (sizeof(LONGFLOAT) == 16) { /* sparc */
- RETURN (__MKSMALLINT(112));
+ RETURN (__MKSMALLINT(112));
}
%}.
"systems without longFloat support use doubles instead"
self basicNew basicSize == Float basicNew basicSize ifTrue:[
- ^ Float numBitsInMantissa
+ ^ Float numBitsInMantissa
].
self error:'missing definition' "ifdef missing in above primitive code for this architecture"
@@ -716,8 +714,8 @@
LONGFLOAT val = __longFloatVal(self);
if (val < (LONGFLOAT)0.0) {
- __qMKLFLOAT(newFloat, -val);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, -val);
+ RETURN ( newFloat );
}
RETURN (self);
%}.
@@ -753,26 +751,26 @@
LONGFLOAT result, val;
if (__isSmallInteger(aNumber)) {
- result = __longFloatVal(self) / (LONGFLOAT)(__intVal(aNumber));
+ result = __longFloatVal(self) / (LONGFLOAT)(__intVal(aNumber));
retResult:
- __qMKLFLOAT(newFloat, result);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, result);
+ RETURN ( newFloat );
}
if (aNumber != nil) {
- if (__qIsLongFloat(aNumber)) {
- result = __longFloatVal(self) / __longFloatVal(aNumber);
- goto retResult;
- }
- if (__qIsFloatLike(aNumber)) {
- val = (LONGFLOAT)(__floatVal(aNumber));
- result = __longFloatVal(self) / val;
- goto retResult;
- }
- if (__qIsShortFloat(aNumber)) {
- val = (LONGFLOAT)(__shortFloatVal(aNumber));
- result = __longFloatVal(self) / val;
- goto retResult;
- }
+ if (__qIsLongFloat(aNumber)) {
+ result = __longFloatVal(self) / __longFloatVal(aNumber);
+ goto retResult;
+ }
+ if (__qIsFloatLike(aNumber)) {
+ val = (LONGFLOAT)(__floatVal(aNumber));
+ result = __longFloatVal(self) / val;
+ goto retResult;
+ }
+ if (__qIsShortFloat(aNumber)) {
+ val = (LONGFLOAT)(__shortFloatVal(aNumber));
+ result = __longFloatVal(self) / val;
+ goto retResult;
+ }
}
%}.
^ aNumber quotientFromLongFloat:self
@@ -815,7 +813,7 @@
if (! isnanl(fVal))
#endif
if ((fVal >= (LONGFLOAT)_MIN_INT) && (fVal <= (LONGFLOAT)_MAX_INT)) {
- RETURN ( __MKSMALLINT( (INT)fVal) );
+ RETURN ( __MKSMALLINT( (INT)fVal) );
}
%}.
^ super asInteger
@@ -1054,23 +1052,23 @@
if (! LONG_isnan(rslt))
# endif
if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super exp
+ ^ super exp
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#exp
- arguments:#()
- errorString:'bad receiver in exp'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#exp
+ arguments:#()
+ errorString:'bad receiver in exp'
!
ln
@@ -1091,35 +1089,35 @@
if (val > 0.0)
# endif
{
- __threadErrno = 0;
- rslt = LONG_log(val);
+ __threadErrno = 0;
+ rslt = LONG_log(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super ln
+ ^ super ln
].
"
an invalid value for logarithm
"
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#ln
- arguments:#()
- errorString:'bad receiver in ln'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#ln
+ arguments:#()
+ errorString:'bad receiver in ln'
!
log10
@@ -1140,35 +1138,35 @@
if (val > 0.0)
# endif
{
- __threadErrno = 0;
- rslt = LONG_log10(val);
+ __threadErrno = 0;
+ rslt = LONG_log10(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super log10
+ ^ super log10
].
"
an invalid value for logarithm
"
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#log10
- arguments:#()
- errorString:'bad receiver in log10'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#log10
+ arguments:#()
+ errorString:'bad receiver in log10'
!
raisedTo:aNumber
@@ -1183,35 +1181,35 @@
OBJ newFloat;
if (__isFloatLike(n)) {
- __threadErrno = 0;
- rslt = LONG_pow(__longFloatVal(self), __floatVal(n));
+ __threadErrno = 0;
+ rslt = LONG_pow(__longFloatVal(self), __floatVal(n));
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super raisedTo:aNumber
+ ^ super raisedTo:aNumber
].
"
an invalid argument (not convertable to float ?)
"
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#raisedTo:
- arguments:(Array with:aNumber)
- errorString:'bad receiver/arg in raisedTo:'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#raisedTo:
+ arguments:(Array with:aNumber)
+ errorString:'bad receiver/arg in raisedTo:'
"Modified: / 16.11.2001 / 14:16:51 / cg"
!
@@ -1234,32 +1232,32 @@
if (val >= 0.0)
# endif
{
- __threadErrno = 0;
- rslt = LONG_sqrt(val);
+ __threadErrno = 0;
+ rslt = LONG_sqrt(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super sqrt
+ ^ super sqrt
].
^ self class
- raise:#imaginaryResultSignal
- receiver:self
- selector:#sqrt
- arguments:#()
- errorString:'bad (negative) receiver in sqrt'
+ raise:#imaginaryResultSignal
+ receiver:self
+ selector:#sqrt
+ arguments:#()
+ errorString:'bad (negative) receiver in sqrt'
"
10 asLongFloat sqrt
@@ -1285,9 +1283,9 @@
OBJ s;
if (__isString(@global(DefaultPrintFormat))) {
- fmt = (char *) __stringVal(@global(DefaultPrintFormat));
+ fmt = (char *) __stringVal(@global(DefaultPrintFormat));
} else {
- fmt = ".9";
+ fmt = ".9";
}
/*
* build a printf format string
@@ -1296,12 +1294,12 @@
strncpy(fmtBuffer+1, fmt, 10);
if (sizeof(LONGFLOAT) == sizeof(double)) {
#ifdef SYSV
- strcat(fmtBuffer, "lg");
+ strcat(fmtBuffer, "lg");
#else
- strcat(fmtBuffer, "G");
+ strcat(fmtBuffer, "G");
#endif
} else {
- strcat(fmtBuffer, "LG");
+ strcat(fmtBuffer, "LG");
}
sprintf(buffer, fmtBuffer, __longFloatVal(self));
@@ -1310,17 +1308,17 @@
* (i.e. look if string contains '.' or 'e' and append '.0' if not)
*/
for (cp = buffer; *cp; cp++) {
- if ((*cp == '.') || (*cp == 'e') || (*cp == 'E')) break;
+ if ((*cp == '.') || (*cp == 'e') || (*cp == 'E')) break;
}
if (!*cp && (cp[-1] >= '0') && (cp[-1] <= '9')) {
- *cp++ = '.';
- *cp++ = '0';
- *cp = '\0';
+ *cp++ = '.';
+ *cp++ = '0';
+ *cp = '\0';
}
s = __MKSTRING(buffer COMMA_SND);
if (s != nil) {
- RETURN (s);
+ RETURN (s);
}
%}.
"
@@ -1373,12 +1371,12 @@
Therefore, this method should be used strictly private.
Notice:
- the need to redefine this method here is due to the
- inability of many machines to store floats in non-double aligned memory.
- Therefore, on some machines, the first <nPad> bytes of a float are left unused,
- and the actual float is stored at index <nPad>+1 ...
- To hide this at one place, this method knows about that, and returns
- values as if this filler wasnt present."
+ the need to redefine this method here is due to the
+ inability of many machines to store floats in non-double aligned memory.
+ Therefore, on some machines, the first <nPad> bytes of a float are left unused,
+ and the actual float is stored at index <nPad>+1 ...
+ To hide this at one place, this method knows about that, and returns
+ values as if this filler wasnt present."
%{ /* NOCONTEXT */
@@ -1391,11 +1389,11 @@
* and SmallInteger
*/
if (__isSmallInteger(index)) {
- indx = __intVal(index) - 1;
- if (((unsigned)(indx)) < sizeof(LONGFLOAT)) {
- cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
- RETURN ( __MKSMALLINT(cp[indx] & 0xFF) );
- }
+ indx = __intVal(index) - 1;
+ if (((unsigned)(indx)) < sizeof(LONGFLOAT)) {
+ cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
+ RETURN ( __MKSMALLINT(cp[indx] & 0xFF) );
+ }
}
%}.
^ self indexNotIntegerOrOutOfBounds:index
@@ -1407,12 +1405,12 @@
Therefore, this method should be used strictly private.
Notice:
- the need to redefine this method here is due to the
- inability of many machines to store floats in non-double aligned memory.
- Therefore, on some machines, the first <nPad> bytes of a float are left unused,
- and the actual float is stored at index <nPad>+1 .. .
- To hide this at one place, this method knows about that, and returns
- values as if this filler wasnt present."
+ the need to redefine this method here is due to the
+ inability of many machines to store floats in non-double aligned memory.
+ Therefore, on some machines, the first <nPad> bytes of a float are left unused,
+ and the actual float is stored at index <nPad>+1 .. .
+ To hide this at one place, this method knows about that, and returns
+ values as if this filler wasnt present."
%{ /* NOCONTEXT */
register int indx, val;
@@ -1424,28 +1422,28 @@
* and SmallInteger
*/
if (__bothSmallInteger(index, value)) {
- val = __intVal(value);
- if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) {
- indx = __intVal(index) - 1;
- if (((unsigned)(indx)) < sizeof(LONGFLOAT)) {
- cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
- cp[indx] = val;
- RETURN ( value );
- }
- }
+ val = __intVal(value);
+ if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) {
+ indx = __intVal(index) - 1;
+ if (((unsigned)(indx)) < sizeof(LONGFLOAT)) {
+ cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
+ cp[indx] = val;
+ RETURN ( value );
+ }
+ }
}
%}.
value isInteger ifFalse:[
- "
- the object to store should be an integer number
- "
- ^ self elementNotInteger
+ "
+ the object to store should be an integer number
+ "
+ ^ self elementNotInteger
].
(value between:0 and:255) ifFalse:[
- "
- the object to store must be a bytes value
- "
- ^ self elementBoundsError:value
+ "
+ the object to store must be a bytes value
+ "
+ ^ self elementBoundsError:value
].
^ self indexNotIntegerOrOutOfBounds:index
!
@@ -1454,12 +1452,12 @@
"return the size in bytes of the float.
Notice:
- the need to redefine this method here is due to the
- inability of many machines to store floats in non-double aligned memory.
- Therefore, on some machines, the first <nPad> bytes of a float are left unused,
- and the actual float is stored at index <nPad>+1 ...
- To hide this at one place, this method knows about that, and returns
- values as if this filler wasnt present."
+ the need to redefine this method here is due to the
+ inability of many machines to store floats in non-double aligned memory.
+ Therefore, on some machines, the first <nPad> bytes of a float are left unused,
+ and the actual float is stored at index <nPad>+1 ...
+ To hide this at one place, this method knows about that, and returns
+ values as if this filler wasnt present."
%{ /* NOCONTEXT */
@@ -1486,7 +1484,7 @@
__threadErrno = 0;
LONG_frexp( __longFloatVal(self), &exp);
if (__threadErrno == 0) {
- RETURN (__MKSMALLINT(exp));
+ RETURN (__MKSMALLINT(exp));
}
#endif
%}.
@@ -1514,26 +1512,26 @@
LONGFLOAT lV = __longFloatVal(self);
if (LONG_finite(lV)) {
- RETURN (true);
+ RETURN (true);
} else {
- RETURN (false);
+ RETURN (false);
}
#else
double dV = (double) __longFloatVal(self);
if (finite(dV)) {
- RETURN (true);
+ RETURN (true);
} else {
- RETURN (false);
+ RETURN (false);
}
#endif
%}
"
- 1.0 asLongFloat isFinite
- (0.0 asLongFloat uncheckedDivide: 0.0) isFinite
- (1.0 asLongFloat uncheckedDivide: 0.0) isFinite
- (-1.0 asLongFloat uncheckedDivide: 0.0) isFinite
+ 1.0 asLongFloat isFinite
+ (0.0 asLongFloat uncheckedDivide: 0.0) isFinite
+ (1.0 asLongFloat uncheckedDivide: 0.0) isFinite
+ (-1.0 asLongFloat uncheckedDivide: 0.0) isFinite
"
!
@@ -1547,24 +1545,24 @@
#ifdef LONG_isnan
LONGFLOAT lV = __longFloatVal(self);
if (LONG_isnan(lV)) {
- RETURN (true);
+ RETURN (true);
} else {
- RETURN (false);
+ RETURN (false);
}
#else
double dV = (double)(__longFloatVal(self));
if (isnan(dV)) {
- RETURN (true);
+ RETURN (true);
} else {
- RETURN (false);
+ RETURN (false);
}
#endif
%}
"
- 1.0 asLongFloat isNaN
- (0.0 asLongFloat uncheckedDivide: 0.0) isNaN
+ 1.0 asLongFloat isNaN
+ (0.0 asLongFloat uncheckedDivide: 0.0) isNaN
"
!
@@ -1633,31 +1631,31 @@
if ((val >= -1.0) && (val <= 1.0))
# endif
{
- __threadErrno = 0;
- rslt = LONG_acos(val);
+ __threadErrno = 0;
+ rslt = LONG_acos(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super arcCos
+ ^ super arcCos
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#arcCos
- arguments:#()
- errorString:'bad receiver in arcCos'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#arcCos
+ arguments:#()
+ errorString:'bad receiver in arcCos'
"
-10 asLongFloat arcCos
@@ -1683,31 +1681,31 @@
if (val >= 1.0)
# endif
{
- __threadErrno = 0;
- rslt = LONG_acosh(val);
+ __threadErrno = 0;
+ rslt = LONG_acosh(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super arcCosh
+ ^ super arcCosh
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#arcCosh
- arguments:#()
- errorString:'bad receiver in arcCosh'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#arcCosh
+ arguments:#()
+ errorString:'bad receiver in arcCosh'
"
-10 asLongFloat arcCosh
@@ -1734,31 +1732,31 @@
if ((val >= -1.0) && (val <= 1.0))
# endif
{
- __threadErrno = 0;
- rslt = LONG_asin(val);
+ __threadErrno = 0;
+ rslt = LONG_asin(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super arcSin
+ ^ super arcSin
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#arcSin
- arguments:#()
- errorString:'bad receiver in arcSin'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#arcSin
+ arguments:#()
+ errorString:'bad receiver in arcSin'
"
-10 asLongFloat arcSin
@@ -1784,31 +1782,31 @@
if (val >= 1.0)
# endif
{
- __threadErrno = 0;
- rslt = LONG_asinh(val);
+ __threadErrno = 0;
+ rslt = LONG_asinh(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super arcSinh
+ ^ super arcSinh
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#arcSinh
- arguments:#()
- errorString:'bad receiver in arcSinh'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#arcSinh
+ arguments:#()
+ errorString:'bad receiver in arcSinh'
"
-10 asLongFloat arcSinh
@@ -1834,24 +1832,24 @@
if (! LONG_isnan(rslt))
# endif
{
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super arcTan
+ ^ super arcTan
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#arcTan
- arguments:#()
- errorString:'bad receiver in arcTan'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#arcTan
+ arguments:#()
+ errorString:'bad receiver in arcTan'
!
arcTanh
@@ -1871,30 +1869,30 @@
if ((val >= -1.0) && (val <= 1.0))
# endif
{
- rslt = LONG_atanh(val);
+ rslt = LONG_atanh(val);
# ifdef LONG_isnan
- if (! LONG_isnan(rslt))
+ if (! LONG_isnan(rslt))
# endif
- {
- if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
- }
- }
+ {
+ if (__threadErrno == 0) {
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super arcTanh
+ ^ super arcTanh
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#arcTanh
- arguments:#()
- errorString:'bad receiver in arcTanh'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#arcTanh
+ arguments:#()
+ errorString:'bad receiver in arcTanh'
!
cos
@@ -1914,22 +1912,22 @@
if (! LONG_isnan(rslt))
# endif
if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super cos
+ ^ super cos
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#cos
- arguments:#()
- errorString:'bad receiver in cos'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#cos
+ arguments:#()
+ errorString:'bad receiver in cos'
!
cosh
@@ -1949,22 +1947,22 @@
if (! LONG_isnan(rslt))
# endif
if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super cosh
+ ^ super cosh
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#cosh
- arguments:#()
- errorString:'bad receiver in cosh'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#cosh
+ arguments:#()
+ errorString:'bad receiver in cosh'
!
sin
@@ -1984,22 +1982,22 @@
if (! LONG_isnan(rslt))
# endif
if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super sin
+ ^ super sin
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#sin
- arguments:#()
- errorString:'bad receiver in sin'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#sin
+ arguments:#()
+ errorString:'bad receiver in sin'
!
sinh
@@ -2019,22 +2017,22 @@
if (! LONG_isnan(rslt))
# endif
if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super sinh
+ ^ super sinh
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#sinh
- arguments:#()
- errorString:'bad receiver in sinh'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#sinh
+ arguments:#()
+ errorString:'bad receiver in sinh'
!
tan
@@ -2054,22 +2052,22 @@
if (! LONG_isnan(rslt))
# endif
if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super tan
+ ^ super tan
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#tan
- arguments:#()
- errorString:'bad receiver in tan'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#tan
+ arguments:#()
+ errorString:'bad receiver in tan'
!
tanh
@@ -2088,22 +2086,22 @@
if (! LONG_isnan(rslt))
# endif
if (__threadErrno == 0) {
- __qMKLFLOAT(newFloat, rslt);
- RETURN ( newFloat );
+ __qMKLFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
}
#else
useFallBack = true;
#endif
%}.
useFallBack notNil ifTrue:[
- ^ super tanh
+ ^ super tanh
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#tanh
- arguments:#()
- errorString:'bad receiver in tanh'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#tanh
+ arguments:#()
+ errorString:'bad receiver in tanh'
! !
!LongFloat methodsFor:'truncation & rounding'!
@@ -2345,7 +2343,7 @@
!LongFloat class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/LongFloat.st,v 1.43 2003-10-30 15:10:46 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/LongFloat.st,v 1.44 2003-10-31 11:15:28 stefan Exp $'
! !
LongFloat initialize!