# HG changeset patch # User Stefan Vogel # Date 1067526368 -3600 # Node ID c3c9115bb492abd92535a8cd740b59c40090442f # Parent 1c8c8024c9024435e1951be4b2d9719e7b3378f1 Define #abs diff -r 1c8c8024c902 -r c3c9115bb492 ShortFloat.st --- a/ShortFloat.st Thu Oct 30 16:03:31 2003 +0100 +++ b/ShortFloat.st Thu Oct 30 16:06:08 2003 +0100 @@ -580,6 +580,28 @@ ^ aNumber quotientFromShortFloat:self ! +abs + "return the absolute value of the receiver + reimplemented here for speed" + +%{ /* NOCONTEXT */ + + OBJ newFloat; + float val = __shortFloatVal(self); + + if (val < 0.0) { + __qMKSFLOAT(newFloat, -val); + RETURN ( newFloat ); + } + RETURN (self); +%}. + + " + 3.0 asShortFloat abs + -3.0 asShortFloat abs + " +! + negated "return myself negated" @@ -1456,5 +1478,5 @@ !ShortFloat class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.81 2003-07-02 09:52:21 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.82 2003-10-30 15:06:08 stefan Exp $' ! !