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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!newspeer1-win.ntli.net!newsfe6-win.ntli.net.POSTED!53ab2750!not-for-mail From: Chris Moore User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Way to use Ada Mod function on floats? References: <1164987168.477589.240140@j44g2000cwa.googlegroups.com> In-Reply-To: <1164987168.477589.240140@j44g2000cwa.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 01 Dec 2006 21:13:19 GMT NNTP-Posting-Host: 82.27.152.73 X-Trace: newsfe6-win.ntli.net 1165007599 82.27.152.73 (Fri, 01 Dec 2006 21:13:19 GMT) NNTP-Posting-Date: Fri, 01 Dec 2006 21:13:19 GMT Organization: NTL Xref: g2news2.google.com comp.lang.ada:7781 Date: 2006-12-01T21:13:19+00:00 List-Id: AAFellow@hotmail.com wrote: > 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. > > Thank you for any help you can provide! > > AA Something like this (I don't have a compiler near me atm) : function Mod (N, M : Float) return Float is I : Integer := Integer (N / M - 0.5); begin if I < 0 then I := I + 1; end if; return N - Float (I) * M; end Mod; Chris -- Sig pending!