Path: news.mathworks.com!newsfeed-00.mathworks.com!oleane.net!oleane!news.ecp.fr!feeder1.cambrium.nl!feeder6.cambrium.nl!feed.tweaknews.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!multikabel.net!feed20.multikabel.net!surfnet.nl!surfnet.nl!seven.news.surf.net!news.wind.surfnet.nl!News.Dal.Ca!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: bug in rem
Date: Tue, 31 Jul 2007 19:55:35 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 27
Message-ID: <f8o43n$s14$1@canopus.cc.umanitoba.ca>
References: <46ae48de$1@news.eftel.com.au> <f8lija$j7o$1@fred.mathworks.com> <46ae685a$1@news.eftel.com.au>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1185911735 28708 192.70.172.160 (31 Jul 2007 19:55:35 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Tue, 31 Jul 2007 19:55:35 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:421937


In article <46ae685a$1@news.eftel.com.au>, ross  <ross@nospam.com> wrote:

>rem and mod should not, by definition, return values that exceed the magnitude 
>of the modulus or radix, and the software should be written to reflect that.
>This is an "absolute" consideration.  IMO the software is broken if it doesn't 
>conform to the expected mathematical behaviour, when that is possible.

The documentation for rem and mod do not indicate that the functions
are the abstract algebraic functions of mathematics. Instead,
the documentation gives explicit formulae for how the result is
produced, and those explicit formulae lead to the results you observed.

This is no different than understanding that the '+' operator
does not implement the abstract algebraic addition of mathematics.
Operators in a computer language are defined by their documented
behaviour, not by the behaviour of mathematical constructs
with similar names. Sometimes the difference is startling,
but I don't think it rises to the level of,
'This is an "absolute" consideration.'.

If you need a language with complete abstract mathematical fidelity
or one in which all computations are arranged to maximize
retention of precision, then Matlab is not the right language
for your purposes.
-- 
  Is there any thing whereof it may be said, See, this is new? It hath
  been already of old time, which was before us.       -- Ecclesiastes