--- a/Float.st Wed Oct 28 17:06:12 1998 +0100
+++ b/Float.st Wed Oct 28 17:17:43 1998 +0100
@@ -685,118 +685,10 @@
^ aNumber asFloat
!
-exponent
- "extract a normalized floats exponent.
- The returned value depends on the float-representation of
- the underlying machine and is therefore highly unportable.
- This is not for general use.
- This assumes that the mantissa is normalized to
- 0.5 .. 1.0 and the floats value is mantissa * 2^exp"
-
-%{ /* NOCONTEXT */
-
- double frexp();
- double frac;
- INT exp;
-
- errno = 0;
- frac = frexp(__floatVal(self), &exp);
- if (errno == 0) {
- if (exp == 0) {
- RETURN (__MKSMALLINT(0));
- }
- RETURN (__MKSMALLINT(exp-1));
- }
-%}.
- ^ self primitiveFailed
-
- "
- 1.0 exponent
- 2.0 exponent
- 3.0 exponent
- 4.0 exponent
- 0.5 exponent
- 0.4 exponent
- 0.25 exponent
- 0.00000011111 exponent
- "
-!
-
-fractionalPart
- "extract the after-decimal fraction part.
- the floats value is
- float truncated + float fractionalPart"
-
-%{ /* NOCONTEXT */
-
- double modf();
- double frac, trunc;
-
- errno = 0;
- frac = modf(__floatVal(self), &trunc);
- if (errno == 0) {
- RETURN (__MKFLOAT(frac));
- }
-%}.
- ^ self primitiveFailed
-
- "
- 1.0 fractionalPart
- 2.0 fractionalPart
- 3.0 fractionalPart
- 4.0 fractionalPart
- 0.5 fractionalPart
- 0.25 fractionalPart
- 3.14159 fractionalPart
- 12345673.14159 fractionalPart
- 123456731231231231.14159 fractionalPart
-
- 3.14159 fractionalPart + 3.14159 truncated
-
- 12345673.14159 fractionalPart + 12345673.14159 truncated
-
- 123456731231231231.14159 fractionalPart + 123456731231231231.14159 truncated
- "
-!
-
generality
"return the generality value - see ArithmeticValue>>retry:coercing:"
^ 80
-!
-
-mantissa
- "extract a normalized floats mantissa.
- The returned value depends on the float-representation of
- the underlying machine and is therefore highly unportable.
- This is not for general use.
- This assumes that the mantissa is normalized to
- 0.5 .. 1.0 and the floats value is mantissa * 2^exp"
-
-%{ /* NOCONTEXT */
-
- double frexp();
- double frac;
- INT exp;
-
- errno = 0;
- frac = frexp(__floatVal(self), &exp);
- if (errno == 0) {
- RETURN (__MKFLOAT(frac));
- }
-%}.
- ^ self primitiveFailed
-
- "
- 1.0 exponent
- 1.0 mantissa
-
- 0.25 exponent
- 0.25 mantissa
-
- 0.00000011111 exponent
- 0.00000011111 mantissa
- "
! !
!Float methodsFor:'comparing'!
@@ -1438,6 +1330,79 @@
^ self subscriptBoundsError:index
! !
+!Float methodsFor:'special access'!
+
+exponent
+ "extract a normalized floats exponent.
+ The returned value depends on the float-representation of
+ the underlying machine and is therefore highly unportable.
+ This is not for general use.
+ This assumes that the mantissa is normalized to
+ 0.5 .. 1.0 and the floats value is mantissa * 2^exp"
+
+%{ /* NOCONTEXT */
+
+ double frexp();
+ double frac;
+ INT exp;
+
+ errno = 0;
+ frac = frexp(__floatVal(self), &exp);
+ if (errno == 0) {
+ if (exp == 0) {
+ RETURN (__MKSMALLINT(0));
+ }
+ RETURN (__MKSMALLINT(exp-1));
+ }
+%}.
+ ^ self primitiveFailed
+
+ "
+ 1.0 exponent
+ 2.0 exponent
+ 3.0 exponent
+ 4.0 exponent
+ 0.5 exponent
+ 0.4 exponent
+ 0.25 exponent
+ 0.00000011111 exponent
+ "
+!
+
+mantissa
+ "extract a normalized floats mantissa.
+ The returned value depends on the float-representation of
+ the underlying machine and is therefore highly unportable.
+ This is not for general use.
+ This assumes that the mantissa is normalized to
+ 0.5 .. 1.0 and the floats value is mantissa * 2^exp"
+
+%{ /* NOCONTEXT */
+
+ double frexp();
+ double frac;
+ INT exp;
+
+ errno = 0;
+ frac = frexp(__floatVal(self), &exp);
+ if (errno == 0) {
+ RETURN (__MKFLOAT(frac));
+ }
+%}.
+ ^ self primitiveFailed
+
+ "
+ 1.0 exponent
+ 1.0 mantissa
+
+ 0.25 exponent
+ 0.25 mantissa
+
+ 0.00000011111 exponent
+ 0.00000011111 mantissa
+ "
+! !
+
!Float methodsFor:'testing'!
isFinite
@@ -1698,6 +1663,43 @@
!
+fractionPart
+ "extract the after-decimal fraction part.
+ the floats value is
+ float truncated + float fractionalPart"
+
+%{ /* NOCONTEXT */
+
+ double modf();
+ double frac, trunc;
+
+ errno = 0;
+ frac = modf(__floatVal(self), &trunc);
+ if (errno == 0) {
+ RETURN (__MKFLOAT(frac));
+ }
+%}.
+ ^ self primitiveFailed
+
+ "
+ 1.0 fractionPart
+ 2.0 fractionPart
+ 3.0 fractionPart
+ 4.0 fractionPart
+ 0.5 fractionPart
+ 0.25 fractionPart
+ 3.14159 fractionPart
+ 12345673.14159 fractionPart
+ 123456731231231231.14159 fractionPart
+
+ 3.14159 fractionPart + 3.14159 truncated
+
+ 12345673.14159 fractionPart + 12345673.14159 truncated
+
+ 123456731231231231.14159 fractionPart + 123456731231231231.14159 truncated
+ "
+!
+
rounded
"return the receiver rounded to the nearest integer"
@@ -1830,6 +1832,6 @@
!Float class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.87 1998-10-28 16:04:15 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.88 1998-10-28 16:17:43 cg Exp $'
! !
Float initialize!