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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,287e8ed2b0c0aabf X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-31 13:15:22 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!cyclone1.gnilink.net!spamfinder.gnilink.net!nwrddc01.gnilink.net.POSTED!53ab2750!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <3D3DED1F.24DE3AC8@lmco.com> <3D46CA0E.BCD17D9C@none.provided> <3D470EEE.811F758D@lmco.com> <719a5d07.0207310251.8f1adef@posting.google.com> <3D483A0B.46EB2F7C@san.rr.com> <1028145549.13341@master.nyc.kbcfp.com> Subject: Re: Zeller's Algorithm X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Message-ID: Date: Wed, 31 Jul 2002 20:15:21 GMT NNTP-Posting-Host: 141.157.176.41 X-Complaints-To: abuse@verizon.net X-Trace: nwrddc01.gnilink.net 1028146521 141.157.176.41 (Wed, 31 Jul 2002 16:15:21 EDT) NNTP-Posting-Date: Wed, 31 Jul 2002 16:15:21 EDT Xref: archiver1.google.com comp.lang.ada:27531 Date: 2002-07-31T20:15:21+00:00 List-Id: "Hyman Rosen" wrote in message news:1028145549.13341@master.nyc.kbcfp.com... > No. It is required in C or C++ that for non-zero b, > a / b * b + a % b == a > > When division rounds towards zero, as is usually desired > (the C++ standard claims that this is what the Fortran > standard requires), this forces the remainder operation > to return negative results. Eg., we want -3 / 2 == -1, > so we must have -3 % 2 == -1 for the requirement to hold. You're absolute right, but with the caveat that the C standard does not require that integer division round to zero. It is acceptable for a C implementation to round to minus infinity, in which case (-3) / 2 == -2 and therefore (-3) % 2 == 1. This decision on the part of the C Standards committee is most unfortunate, since as Mr. Rosen correctly indicates, virtually all platforms round to zero. Life could have been made simpler for C programmers if this was required for all implementations, but apparently there was some platform, with politically powerful allies, that did not round to zero.