ShortFloat.st
changeset 14719 a354c1ef4a56
parent 14718 01835f8e7bab
child 14727 10825e6940d3
child 18017 7fef9e17913f
equal deleted inserted replaced
14718:01835f8e7bab 14719:a354c1ef4a56
   169 
   169 
   170     In contrast to Floats (which use the C-compilers 64bit 'double' format),
   170     In contrast to Floats (which use the C-compilers 64bit 'double' format),
   171     ShortFloats give you 32 bit floats.
   171     ShortFloats give you 32 bit floats.
   172 
   172 
   173     Notice, that ST/X Floats are what Doubles are in ST-80 and ShortFloats are
   173     Notice, that ST/X Floats are what Doubles are in ST-80 and ShortFloats are
   174     ST-80's Floats respectively.
   174     ST-80's Floats respectively. The reason was to make ST/X's floats compatible
       
   175     to bothe visualWorks and other smalltalks, which use C-doubles for the Float class.
       
   176     Thus, STX's Float precision is not worse than that of other ST's.
       
   177 
   175     This may change in one of the next versions (at least on machines, which
   178     This may change in one of the next versions (at least on machines, which
   176     provide different float and double types in their C-compiler.
   179     provide different float and double types in their C-compiler.
   177 
   180 
   178     WARNING:
   181     WARNING:
   179 	The layout of shortFloat instances is known by the runtime system and the compiler;
   182 	The layout of shortFloat instances is known by the runtime system and the compiler;
  1654     float frac, trunc;
  1657     float frac, trunc;
  1655 
  1658 
  1656     __threadErrno = 0;
  1659     __threadErrno = 0;
  1657     frac = modff(__shortFloatVal(self), &trunc);
  1660     frac = modff(__shortFloatVal(self), &trunc);
  1658     if (! isnan(frac)) {
  1661     if (! isnan(frac)) {
  1659         if (__threadErrno == 0) {
  1662 	if (__threadErrno == 0) {
  1660             RETURN (__MKSFLOAT(frac));
  1663 	    RETURN (__MKSFLOAT(frac));
  1661         }
  1664 	}
  1662     }
  1665     }
  1663 %}.
  1666 %}.
  1664     ^ self class
  1667     ^ self class
  1665         raise:#domainErrorSignal
  1668 	raise:#domainErrorSignal
  1666         receiver:self
  1669 	receiver:self
  1667         selector:#fractionPart
  1670 	selector:#fractionPart
  1668         arguments:#()
  1671 	arguments:#()
  1669         errorString:'bad receiver in fractionPart'
  1672 	errorString:'bad receiver in fractionPart'
  1670 
  1673 
  1671     "
  1674     "
  1672      1.6 asShortFloat fractionPart + 1.6 asShortFloat truncated
  1675      1.6 asShortFloat fractionPart + 1.6 asShortFloat truncated
  1673      -1.6 asShortFloat fractionPart + -1.6 asShortFloat truncated
  1676      -1.6 asShortFloat fractionPart + -1.6 asShortFloat truncated
  1674 
  1677 
  1846 ! !
  1849 ! !
  1847 
  1850 
  1848 !ShortFloat class methodsFor:'documentation'!
  1851 !ShortFloat class methodsFor:'documentation'!
  1849 
  1852 
  1850 version
  1853 version
  1851     ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.114 2013-01-25 17:32:56 stefan Exp $'
  1854     ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.115 2013-01-26 15:03:23 cg Exp $'
  1852 !
  1855 !
  1853 
  1856 
  1854 version_CVS
  1857 version_CVS
  1855     ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.114 2013-01-25 17:32:56 stefan Exp $'
  1858     ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.115 2013-01-26 15:03:23 cg Exp $'
  1856 ! !
  1859 ! !
  1857 
  1860