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,b61052ba3fdc8c26 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-01 07:46:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!csampson From: csampson@inetworld.net (Charles Sampson) Newsgroups: comp.lang.ada Subject: Re: Integers and Mathematical Correctness Date: Thu, 1 Nov 2001 07:45:43 -0800 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <1f26o22.1xfvwvo111pfi4N%csampson@inetworld.net> References: User-Agent: MacSOUP/2.4.6 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:15542 Date: 2001-11-01T07:45:43-08:00 List-Id: chris.danx wrote: > Hi, > > To most this may seem insignificant but I'm more mathematically minded and I > just found something out. Many programming languages don't implement > division properly! > > For example -3/2 should be -2 not -1, with a remainder 1 not -1. > > I'm trying to implement integer division the "proper" way (according to > Euclid), just for fun (and to provide a mathematically correct package for > anyone who gets annoyed by this). I'm not sure how you determined that the "proper" definition of integer division is to return floor (a/b), where "/" is mathematical division. The definition used by most programming languages preserves the very useful property -(a/b) = (-a)/b = a/(-b), where this time "/" represents integer division. Please explain the Euclid reference. I don't have any History of Mathematics books available, but I don't remember that Euclid had nega- tive numbers to work with. Charlie