From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fc647120984c9ad2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!208.49.83.146.MISMATCH!uns-out.usenetserver.com!news.usenetserver.com!pc03.usenetserver.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Way to use Ada Mod function on floats? References: <1164987168.477589.240140@j44g2000cwa.googlegroups.com> From: Stephen Leake Date: Sat, 02 Dec 2006 06:11:34 -0500 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt) Cancel-Lock: sha1:SUJUPhoPdBZAqIrg6jzAD8+o1PE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 958b845715f6c759e00d423588 Xref: g2news2.google.com comp.lang.ada:7782 Date: 2006-12-02T06:11:34-05:00 List-Id: "AAFellow@hotmail.com" writes: > Hi guys, > > I need to perform the mod operation on floats. Does anyone know of a > simple way to do this in Ada? It seems the mod function is only for > integers. I can probably multiply out the decimal places, and then > divide my answer back, but if there is a more simple way that saves > computations, I'd rather do that. SAL (http://stephe-leake.org/ada/sal.html) has: function Modulo (Dividend, Divisor : in Real_Type) return Real_Type is -- match names in Ada LRM 4.5.5 A : Real_Type renames Dividend; B : Real_Type renames Divisor; N : constant Integer := Integer (Real_Type'Floor (A / B)); begin return A - B * Real_Type (N); end Modulo; -- -- Stephe