Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'properly.': 0.07; 'behave': 0.09; 'received:internal': 0.09; 'python': 0.11; 'translate': 0.15; 'wed,': 0.15; 'c/c++,': 0.16; 'considers': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'operands': 0.16; 'operands.': 0.16; 'operation,': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'wrote:': 0.16; 'odd': 0.18; 'math': 0.20; 'changes': 0.20; 'java': 0.22; 'header:In-Reply- To:1': 0.24; 'question': 0.26; 'division': 0.29; 'guess': 0.29; 'values': 0.30; 'languages': 0.34; 'to:addr:python-list': 0.35; 'involving': 0.35; 'there': 0.36; 'subject:" ': 0.36; 'should': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'stuff': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'why': 0.40; 'back': 0.61; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.62; 'skip:n 10': 0.63; 'different': 0.64; 'results': 0.66; 'jul': 0.72; 'article': 0.77; 'subject:value': 0.91 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=HoHJU8wa5lqwzAy5WBznokRGJcw=; b=cSTS5O 3HGWBl+swLUW6iRo5EDt9OPStlalhEoawt5w3WuNyXEINdho2kuDwVNUn5FTe0UR OCr6crYTegaVx4//65kwWHuyoOGO0J1AbkRvd6h9IOhMfa7en/QkbFKGJExsiB6p iPS6keFQNDQuMRWGLXYTmGrwTJEKM8rZ4t09E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=HoHJU8wa5lqwzAy 5WBznokRGJcw=; b=n8m/fUX30FpYahZnpWV+E0qSG4MOiPmh81/j+CAeOP9vGJ3 aLgmcoygIXImKvYHV0YMHCiDbc5vqI5WfOtEgXSBi3XO42U9YM3u7ILjvQWuXyJe l++SLhsdlHZJ0xlPh9OxrHBaUvy6RlIWrSSZo2lGkLRCMcJKlRaIdVNgGf8s= X-Sasl-Enc: G38tiSfCZXVW9rQgUkJWgvIlwD4ZLyX0zuMoecck0/u7 1435803785 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-eecef38c In-Reply-To: <948e2800-e52b-429a-9e00-f268fcff5085@googlegroups.com> References: <948e2800-e52b-429a-9e00-f268fcff5085@googlegroups.com> Subject: Re: "normalizing" a value Date: Wed, 01 Jul 2015 22:23:05 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435803787 news.xs4all.nl 2954 [2001:888:2000:d::a6]:50562 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:93405 On Wed, Jul 1, 2015, at 21:49, bvdp wrote: > Interesting that negative values translate properly. That's an > non-intuitive result to me. Guess I should have studied that math stuff > harder way back when! There are multiple interpretations of the operation, and not all languages behave the same way as Python does with negative operands. Python is the odd one out when one considers C/C++, C#, and Java which all behave a different way. In general, almost all languages behave in a way so that given q, r = a // b, a % b; q * b + r == a. However, this simply changes the question to how division results involving negative operands are rounded. Here's an article by GvR about why python behaves the way it does: http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html