--- a/ShortFloat.st Tue Dec 03 19:45:05 2019 +0100
+++ b/ShortFloat.st Tue Dec 03 19:49:53 2019 +0100
@@ -2423,6 +2423,49 @@
"
!
+integerAndFractionParts
+ "return the integer and the fraction part of the receiver as a pair
+ of floats (i.e. the result of the modf function)
+ Adding the parts gives the original value"
+
+ |integerPart fractionPart|
+
+%{
+#ifdef __SCHTEAM__
+ ERROR("unimplemented");
+#else
+ float fVal, iPart, fPart;
+ OBJ i, f;
+
+ fVal = __shortFloatVal(self);
+# ifdef NO_MODFF
+ {
+ double dFrac, dTrunc;
+
+ dFrac = modf((double)fVal, &dTrunc) ;
+ fPart = (float)dFrac;
+ iPart = (float)dTrunc;
+ }
+# else
+ fPart = modff(fVal, &iPart);
+# endif
+ __qMKSFLOAT(i, iPart);
+ __qMKSFLOAT(f, fPart);
+ integerPart = i;
+ fractionPart = f;
+#endif
+%}.
+ integerPart isNil ifTrue:[^ super integerAndFractionParts].
+ ^ { integerPart . fractionPart }
+
+ "
+ 0.5 asShortFloat integerAndFractionParts
+ -0.5 asShortFloat integerAndFractionParts
+ 12345.6789 asShortFloat integerAndFractionParts
+ -12345.6789 asShortFloat integerAndFractionParts
+ "
+!
+
rounded
"return the receiver rounded to the nearest integer"