Article View: comp.lang.java
Article #63Re: Correct mod/rem (was: Problem with % (remainder) operator
From: Harlan Messinger
Date: Mon, 22 Jan 1996 20:47
Date: Mon, 22 Jan 1996 20:47
25 lines
2220 bytes
2220 bytes
Henry Baker (hbaker@netcom.com) wrote: : To summarize, the 'correct' mod is one that produces remainders that follow : the _divisor_, and therefore the 'correct' quotient is the _floor_ function. In other words, computers should be programmed to flunk number theory and group theory, not to mention trigonometry (I'd love to see what you think a sine curve looks like around the vertical axis). Wonderful. The point of arithmetic modulo n is that the same cycle of numbers repeats ad infinitum from 0 to (n - 1). It doesn't switch gears at zero. And "remainder" is defined as the unique NON-NEGATIVE number greater than equal to 0 but less than the divisor that is left over when the product of the divisor and some integer (quotient) is subtracted from the dividend. These definitions of modulus and remainder are well founded and old, and are useful in a large number of fields. (Quick: if there had been clocks as we know them back then, what number would the little hand have been on ten minutes before the opening moment of January 1 of the year 1: 10 or 2?) These concepts weren't just first invented to make life convenient for programmers, and the software industry shouldn't pretend to own these concepts any more than they should expect to use a non-standard definition for addition or cosine. Certainly there are occasions when what you want for your programming task is the other way around, but that is a different function.
Technical Details
Message-ID:
<4e0t5m$sci@clarknet.clark.net>Path:
arc1-ca.pugleaf.net!news.clark.net!not-for-mailReferences:
<4dc86s$gha@news.xs4all.nl> <4d8hnd$74h@news.xs4all.nl> <443322587wnr@almide.demon.co.uk> <142091149wnr@almide.demon.co.uk> <4dguci$le3@news.ox.ac.uk> <hbaker-2201961022380001@10.0.2.15>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.clark.net!not-for-mail From: gusty@clark.net (Harlan Messinger) Newsgroups: comp.lang.java,comp.lang.c,comp.lang.c++ Subject: Re: Correct mod/rem (was: Problem with % (remainder) operator Followup-To: comp.lang.java,comp.lang.c,comp.lang.c++ Date: 22 Jan 1996 20:47:50 GMT Organization: Clark Internet Services, Inc., Ellicott City, MD USA Message-ID: <4e0t5m$sci@clarknet.clark.net> References: <4dc86s$gha@news.xs4all.nl> <4d8hnd$74h@news.xs4all.nl> <443322587wnr@almide.demon.co.uk> <142091149wnr@almide.demon.co.uk> <4dguci$le3@news.ox.ac.uk> <hbaker-2201961022380001@10.0.2.15> NNTP-Posting-Host: explorer.clark.net Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit