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,287e8ed2b0c0aabf X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-31 12:14:10 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshosting.com!news-xfer1.newshosting.com!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Zeller's Algorithm Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Wed, 31 Jul 2002 19:13:37 GMT References: <3D3DED1F.24DE3AC8@lmco.com> <3D46CA0E.BCD17D9C@none.provided> <3D470EEE.811F758D@lmco.com> <719a5d07.0207310251.8f1adef@posting.google.com> NNTP-Posting-Host: shell01.theworld.com Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:27528 Date: 2002-07-31T19:13:37+00:00 List-Id: "Frank J. Lhota" writes: > > This may be a problem in languages > > such as C, where e.g. -30 % 7 = -2. > > Actually, the C standard does not require that (-30) % 7 == (-2). The > standard has somewhat loose requirements here that would allow the C "%" > operator to behave either like the Ada "rem" operator, or like the Ada "mod" > operator. The drive to standardize C, unfortunately, came after there were > many divergent implementations of the language. The need to validate > existing implementations tied the hands of the standards committee. Doesn't this make the % operator totally useless for negative numbers? I mean, how do you write code that gets some useful "right" answer, if you're doing % on negative numbers? - Bob