From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 8A2AD7F0EF for ; Wed, 27 Jan 2016 15:00:38 +0100 (CET) IronPort-PHdr: 9a23:7m+r7hQLtQsCFVHCHPvRQwzc6tpsv+yvbD5Q0YIujvd0So/mwa64Zx2N2/xhgRfzUJnB7Loc0qyN4/+mATZLvcfJmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4bt74BpTVx5zukbvipNuLOU4U1XKUWvBbElaflU3prM4YgI9veO4a6yDihT92QdlQ3n5iPlmJnhzxtY+a9Z9n9DlM6bp6r5YTGfayQ6NtRrVdCHEiMnspzMztrxjKCwWVtVUGVWBDshdODxLE71nQWZD0+n/6u+xxwiiZFdHxVbc1Hyyl6L4tQxjt3nRUfwUl+X3a35QjxJlQpwis8kRy Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=hendrik@topoi.pooq.com; spf=None smtp.mailfrom=hendrik@topoi.pooq.com; spf=None smtp.helo=postmaster@april.topoi.pooq.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of hendrik@topoi.pooq.com) identity=pra; client-ip=69.165.131.134; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="hendrik@topoi.pooq.com"; x-sender="hendrik@topoi.pooq.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of hendrik@topoi.pooq.com) identity=mailfrom; client-ip=69.165.131.134; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="hendrik@topoi.pooq.com"; x-sender="hendrik@topoi.pooq.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@april.topoi.pooq.com) identity=helo; client-ip=69.165.131.134; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="hendrik@topoi.pooq.com"; x-sender="postmaster@april.topoi.pooq.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DwBAB5zKhW/4aDpUVeToQGgwqFcrM+hg8CggEQAQEBAQEBAQGBCYItghUBAQQ6TwsYCSUPBRiIX71oAQEIAh6KS4UFgmCBDwWOIYhajU0JYY4ZjkM3K4QKHohzAQEB X-IPAS-Result: A0DwBAB5zKhW/4aDpUVeToQGgwqFcrM+hg8CggEQAQEBAQEBAQGBCYItghUBAQQ6TwsYCSUPBRiIX71oAQEIAh6KS4UFgmCBDwWOIYhajU0JYY4ZjkM3K4QKHohzAQEB X-IronPort-AV: E=Sophos;i="5.22,354,1449529200"; d="scan'208";a="161887073" Received: from topoi.pooq.com (HELO april.topoi.pooq.com) ([69.165.131.134]) by mail3-smtp-sop.national.inria.fr with ESMTP; 27 Jan 2016 15:00:34 +0100 Received: by april.topoi.pooq.com (Postfix, from userid 1001) id DE2A01A04D2; Wed, 27 Jan 2016 05:02:54 -0500 (EST) Date: Wed, 27 Jan 2016 05:02:54 -0500 From: Hendrik Boom To: caml-list@inria.fr Message-ID: <20160127100254.GB2762@topoi.pooq.com> References: <1453854887.31205.2.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1453854887.31205.2.camel@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] truncated division, remainder and arithmetics On Wed, Jan 27, 2016 at 01:34:47AM +0100, peio wrote: > Good evening, > > > while doing some modular arithmetic I discovered that OCaml uses the > 'truncated division' convention for the `/` (quotient) operator. > Actually this convention may seem innocent but it greatly affects the > `mod` (remainder) operator: the sign of the result is the same as > dividend. > > After some research I realized that lots of people (D.Knuth!) > criticized this convention in favor of floored division (sign of > remainder same as divisor) or euclidean division (remainder always > positive). I know such a key component of the language isn't likely to > be changed but I would like to get some of the rationals behind this > decision. In the old days when all machines hadn't settled down to one true binary arithmetic convention, I noticed that the machines where the remainder had the same sign as the dividend were two's complement machines, and the ones where the remainder had the same sign as the divisor were one's complement machines. -- hendrik