From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 22 Nov 91 15:24:26 GMT From: milo!chrisp@uunet.uu.net (The Sunset Kid) Subject: Re: Red-faced professor gets bitten in search for portability Message-ID: <1991Nov22.152426.25797@verdix.com> List-Id: In article <1991Nov22.090650.28@v7.vitro.com> vaxs09@v7.vitro.com writes: > > FUNCTION Trunc ( X : Float ) RETURN Integer IS > i : integer := integer ( x ); > if x < float(i) then > return i - 1; > else > return i; > endif; > END Trunc; This version will not work for negative numbers. If X is less than zero, then a proper truncation would leave X < Float (I), subsequently subtracting 1, and returning -2 for a parameter of -1.25. Of course, I rarely use negative numbers, so change all your INTEGERs to NATURALs and you'll have a pretty efficient truncator for non-negative integers. By the way, putting ABS calls in this thing would turn it into a real mess... anyone else got an easier way of handling negatives? C.A. Piepenbring