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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,efbbbab26bad9cb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-16 05:34:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-pas-nf2!elnk-pas-nf1!newsfeed.earthlink.net!sn-xit-02!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: how to round integers (Figured it out!) Date: Mon, 16 Jun 2003 07:34:07 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:39241 Date: 2003-06-16T07:34:07-05:00 List-Id: It's simpler to just add one less than the divisor to the dividend before dividing. "Cephus�" wrote in message news:verddee9cbo317@corp.supernews.com... > > > Cephus� wrote: > > I am trying to remember the "golden rule" for integer division > > rounding. > > > > I am trying to average something (both integers) and I can't remember > > how to round without using floating point. > > > > Like say I am trying to divide 26/3 --- I would get 8 remainder 2 > > > > but that should round up to 9. How can I do this? I know it has > > something to do with the dividend....but I can't for the life of me > > remember. thanks! > > > > Beau > > I figured it out. Thanks for the help (although I was asking how to do > something, not the code to do it, usually you would never get that in a > newsgroup). > > All you do is REM the divisor and dividend. Then double it. If that number > is greater than the divisor, then add one. Otherwise don't... > > Beau > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >