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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Way to use Ada Mod function on floats? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1164987168.477589.240140@j44g2000cwa.googlegroups.com> <4571ac78_6@news.bluewin.ch> Date: Sat, 2 Dec 2006 19:21:43 +0100 Message-ID: NNTP-Posting-Date: 02 Dec 2006 19:21:26 CET NNTP-Posting-Host: fa502b13.newsspool2.arcor-online.net X-Trace: DXC=NV\C5749gBSPU8j_I0DN6_A9EHlD;3YcR4Fo<]lROoRQFl8W>\BH3YRe_KGaoFYJ?]DNcfSJ;bb[UIRnRBaCd On Sat, 02 Dec 2006 17:48:34 +0000, Simon Wright wrote: > Gautier writes: > >> Stephen Leake: >> >>> 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; >> >> Out of curiosity, what is the need of converting Real_Type'Floor (A / >> B) to an Integer and back to a Real_Type ? > > Especially when it can overflow and give you a Constraint_Error. Hmm, why is it converted to integer? I would stay all the way in Real_Type'Base: return Real_Type'Base (Dividend - Divisor * Real_Type'Base'Floor (Dividend / Divisor)); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de