class: ShortFloat
changed:
#isNegativeZero
#negative
#positive
--- a/ShortFloat.st Tue Feb 03 15:17:09 2015 +0100
+++ b/ShortFloat.st Tue Feb 03 15:17:43 2015 +0100
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libbasic' }"
+"{ NameSpace: Smalltalk }"
+
LimitedPrecisionReal variableByteSubclass:#ShortFloat
instanceVariableNames:''
classVariableNames:'DefaultPrintFormat Epsilon'
@@ -335,7 +337,6 @@
^ Epsilon
! !
-
!ShortFloat class methodsFor:'binary storage'!
readBinaryIEEESingleFrom:aStream
@@ -1633,11 +1634,8 @@
"many systems have two float.Pnt zeros"
%{
-#if defined(__i386__) && defined(linux)
- RETURN ((__ByteArrayInstPtr(self)->ba_element[sizeof(float)-1] == 128) ? true : false );
-#endif
+ RETURN ( (__shortFloatVal(self) == 0.0 && signbit(__shortFloatVal(self)) != 0) ? true : false );
%}.
- ^ super isNegativeZero
"
0.0 asShortFloat isNegativeZero
@@ -1646,12 +1644,23 @@
!
negative
- "return true if the receiver is less than zero"
+ "return true if the receiver is less than zero.
+ -0.0 is positive for now."
%{ /* NOCONTEXT */
- RETURN ( (__shortFloatVal(self) < 0.0) ? true : false );
+ RETURN ( __shortFloatVal(self) < 0.0 ? true : false );
+ // RETURN ( signbit(__shortFloatVal(self)) != 0 ? true : false );
%}.
+
+ "
+ 0.0 asShortFloat negative
+ -0.0 asShortFloat negative
+ 1.0 asShortFloat negative
+ -1.0 asShortFloat negative
+ (1.0 uncheckedDivide: 0.0) asShortFloat negative
+ (-1.0 uncheckedDivide: 0.0) asShortFloat negative
+ "
!
numberOfBits
@@ -1672,12 +1681,23 @@
!
positive
- "return true if the receiver is greater or equal to zero"
+ "return true if the receiver is greater or equal to zero
+ 0.0 and -0.0 are positive for now."
%{ /* NOCONTEXT */
- RETURN ( (__shortFloatVal(self) >= 0.0) ? true : false );
-%}
+ RETURN ( __shortFloatVal(self) >= 0.0 ? true : false );
+// RETURN ( (signbit(__shortFloatVal(self)) == 0 ? true : false ) );
+%}.
+
+ "
+ 0.0 asShortFloat positive
+ -0.0 asShortFloat positive
+ 1.0 asShortFloat positive
+ -1.0 asShortFloat positive
+ (1.0 uncheckedDivide: 0.0) asShortFloat positive
+ (-1.0 uncheckedDivide: 0.0) asShortFloat positive
+ "
!
strictlyPositive
@@ -2013,11 +2033,11 @@
!ShortFloat class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.132 2014-12-16 12:19:17 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.133 2015-02-03 14:17:43 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.132 2014-12-16 12:19:17 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.133 2015-02-03 14:17:43 stefan Exp $'
! !