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 06:12:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!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 08:12:40 -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:39243 Date: 2003-06-16T08:12:40-05:00 List-Id: You are quite right. I was thinking of the algorithm which always rounds up if there is any remainder -- e.g., if you need to know how many boxes are required to ship N items, if M items will fit in a box. The algorithm you need (which will do the job without any comparisons and conditional operations is (Dividend + Dividend + Divisor) / (Divisor + Divisor) "Cephus�" wrote in message news:vereehn58o9be1@corp.supernews.com... > > > David C. Hoos wrote: > > It's simpler to just add one less than the divisor to the dividend > > before dividing. > > > well look at if the total is 25. in your example, 25+3-1 = 27. That would > give you 27/3 = 9 > > but it is really 25/3 which equals 8 remainder 1 which is not enough to > round up... > > Beau > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >