Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.91.MISMATCH!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.170 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.68; '*S*': 0.02; 'received:internal': 0.09; 'wed,': 0.15; '20:12,': 0.16; 'message- id:@webmail.messagingengine.com': 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; 'seems': 0.24; 'header:In-Reply-To:1': 0.24; '(this': 0.24; "i'm": 0.29; 'convert': 0.29; 'values': 0.30; 'e.g.': 0.31; 'gives': 0.35; 'to:addr:python-list': 0.35; '(and': 0.36; 'subject:" ': 0.36; 'received:10': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.39; 'sure': 0.40; 'where': 0.40; 'called': 0.40; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.62; 'results.': 0.63; 'places': 0.64; '12.': 0.66; 'jul': 0.72; 'unusual': 0.72; 'music': 0.78; '12:': 0.84; 'do:': 0.91; 'ranging': 0.91; 'results,': 0.91; '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=3Q0VZorqbv+PqCsDmVND5jBld4U=; b=tMZt+P S+YpbqJiXK29CjSphWMKMMDHXw8++Rzge6ZBp7Ne2vOiJnmS48rC4Ewg5mu6d5ff kz9hLPvQSRkiRiXsoRQYSo2S3uo9IfiVN1AvQwluUI40Q5aXF5FTvm7egZcZD9Fa ZO/mOyMi58YcxOM9Tun5TgwAnIJecPN9gIHbU= 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=3Q0VZorqbv+PqCs DmVND5jBld4U=; b=OL2fBwrqB2r0m3AQPk2CWQhFuOJW+5TjnwGrQy7tM2zZym1 Jno3wPATp3JDa4jTtF44Q+IgPCqpcvsK9ZJMwj5mV7CiZvuFfYgsoKv3Gt01Cg2f RXJpwrYRNMrqZsFk0PJ7uKGyxFSTLo2XnkGBNBxpAtS85Y7gX6DY/WUchB0w= X-Sasl-Enc: skfqYPwhpOl3scLOhmOqlggvp19N30rM7sGeFywEygYu 1435800456 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: References: Subject: Re: "normalizing" a value Date: Wed, 01 Jul 2015 21:27:36 -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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435800465 news.xs4all.nl 2848 [2001:888:2000:d::a6]:35858 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93400 On Wed, Jul 1, 2015, at 20:12, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps > "scaling"? > > Anyway, I need to convert various values ranging from around -50 to 50 to > an 0 to 12 range (this is part of a MIDI music program). I have a number > of places where I do: > > while x < 0: x += 12 > while x >= 12: x -= 12 And this gives you what you want? With e.g. 13=1, 14=2, 22=10, 23=11, 24=0, 25 = 1, etc. Seems unusual that that's what you would want. Also note this gives an 0 to 11 range for the results, not 0 to 12. Anyway, x %= 12 will give the same results.