Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!amsnews11.chello.com!newsgate.cistron.nl!newsgate.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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; '128': 0.09; '21,': 0.09; 'prefix': 0.09; 'to:addr:comp.lang.python': 0.09; 'binary': 0.13; 'doing,': 0.16; 'hexadecimal': 0.16; 'manipulating': 0.16; 'ordinal': 0.16; '(i.e.': 0.17; 'wrote:': 0.18; '(which': 0.19; '(or': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.212.46': 0.23; 'received:mail-vw0-f46.google.com': 0.23; 'appear': 0.23; 'noticed': 0.24; "i'm": 0.26; 'bit': 0.28; 'assuming': 0.29; 'nov': 0.29; 'pm,': 0.29; 'values': 0.32; 'value.': 0.32; "isn't": 0.33; 'message-id:@gmail.com': 0.33; 'rather': 0.33; 'to:addr :python-list': 0.34; 'received:209.85.212': 0.34; 'to:no real name:2**1': 0.35; 'subject:/': 0.35; 'subject:with': 0.36; 'charset:us-ascii': 0.37; 'but': 0.37; 'received:192': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'not,': 0.37; 'received:209.85': 0.38; 'should': 0.39; 'subject: (': 0.40; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'received:192.168': 0.40; 'difference': 0.40; 'to:2**2': 0.61; 'header:Message-Id:1': 0.62; 'number.': 0.66; 'high': 0.67; '128,': 0.84; 'subject:Serial': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=mmJYnD4tsmq6+IRRNuqeHVPQ6JQuLe1iKgwQiIpiaKM=; b=EkoRRIcQHNFNdEtH8OaIolREaRDFD8yRFWAhX0H7hZAlrHN+tXU7kuhNM62DznsHeY CZXSZ4XLS85v9ArgLWWiCfKyylV3mtLob91CIXljhANRPtFXr0sNglCamcD/DF3pOFYi 8eoEb5Tyo5PkfNcTHPXVCRvVwSxIYOPGtJ59g= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1251.1) Subject: Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. From: David Riley In-Reply-To: <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Date: Mon, 21 Nov 2011 15:42:23 -0500 Content-Transfer-Encoding: quoted-printable References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> To: comp.lang.python@googlegroups.com, Matthew Lenz , python-list@python.org X-Mailer: Apple Mail (2.1251.1) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321908148 news.xs4all.nl 6865 [2001:888:2000:d::a6]:39890 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16049 On Nov 21, 2011, at 2:29 PM, Matthew Lenz wrote: > Another thing I noticed is that the & and | appear to give the same = result as adding or subtracting 128 from the ordinal value. I'm = assuming that isn't coincidence. :) It's not, though the difference is important. They're binary ANDs (&) = and ORs (|), so (0x0F | 0x80) =3D 0x8F, but (0x8F | 0x80) =3D 0x8F as = well, whereas (0x8F + 0x80) =3D 0x10F. For manipulating bit values = (which is what you're doing, you should almost never be adding or = subtracting, but rather ANDing and ORing (or XORing, but not nearly as = often). Just in case you're not familiar, 0x is the prefix for a hexadecimal = number. 0x80 =3D 128, which is binary 10000000 (i.e. the high bit in a = byte). - Dave=