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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,efbbbab26bad9cb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-19 16:40:27 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-pas-nf2!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3EF249D6.5050904@spam.com> From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: how to round integers (Figured it out!) References: <3EEE9C81.7030904@attbi.com> <3EEF6A62.5010809@spam.com> <3EF03178.9000908@attbi.com> <3EF0AA68.7020901@spam.com> <3EF10509.7040103@attbi.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 19 Jun 2003 23:40:27 GMT NNTP-Posting-Host: 63.184.0.158 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1056066027 63.184.0.158 (Thu, 19 Jun 2003 16:40:27 PDT) NNTP-Posting-Date: Thu, 19 Jun 2003 16:40:27 PDT Xref: archiver1.google.com comp.lang.ada:39465 Date: 2003-06-19T23:40:27+00:00 List-Id: Thanks for the timings. I suspected that converting to floating-point would be faster. Robert I. Eachus wrote: > > generic > type Int is range <>; > function Rounding2(Dividend, Divisor: Int) return Int; > > function Rounding2(Dividend, Divisor: Int) return Int is > begin > return Int(Long_Float(Dividend)/Long_Float(Divisor)); > end Rounding2; Except that Long_Float is (technically) not portable; implementations are not required to define Long_Float. So I guess the fully portable way to implement this would be with System; function Rounding2 (Dividend, Divisor: Int) return Int is type Big is digits System.Max_Digits; begin -- Rounding2 return Int (Big (Dividend) / Big (Divisor) ); end Rounding2; -- Jeff Carter "You cheesy lot of second-hand electric donkey-bottom biters." Monty Python & the Holy Grail