Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16007 > unrolled thread

Non-POSIX parity (mark/space) with Python-Serial on Linux.

Started bymlenz@nocturnal.org
First post2011-11-21 06:00 -0800
Last post2011-11-22 11:32 +1100
Articles 4 on this page of 24 — 8 participants

Back to article view | Back to comp.lang.python


Contents

  Non-POSIX parity (mark/space) with Python-Serial on Linux. mlenz@nocturnal.org - 2011-11-21 06:00 -0800
    Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 06:16 -0800
    Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Nizamov Shawkat <nizamov.shawkat@gmail.com> - 2011-11-21 15:26 +0100
      Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 08:28 -0800
        Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Chris Angelico <rosuav@gmail.com> - 2011-11-22 03:41 +1100
        Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. David Riley <fraveydank@gmail.com> - 2011-11-21 11:47 -0500
          Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 08:52 -0800
          Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 08:52 -0800
            Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. David Riley <fraveydank@gmail.com> - 2011-11-21 12:22 -0500
              Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 09:59 -0800
              Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 09:59 -0800
                Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. David Riley <fraveydank@gmail.com> - 2011-11-21 13:12 -0500
            Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. MRAB <python@mrabarnett.plus.com> - 2011-11-21 18:20 +0000
        Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. gene heskett <gheskett@wdtv.com> - 2011-11-21 12:25 -0500
        Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. David Riley <fraveydank@gmail.com> - 2011-11-21 12:50 -0500
      Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 08:28 -0800
    Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. gene heskett <gheskett@wdtv.com> - 2011-11-21 13:33 -0500
      Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 11:29 -0800
        Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Grant Edwards <invalid@invalid.invalid> - 2011-11-21 19:42 +0000
      Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Matthew Lenz <matthew@nocturnal.org> - 2011-11-21 11:29 -0800
        Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. David Riley <fraveydank@gmail.com> - 2011-11-21 15:42 -0500
          Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Grant Edwards <invalid@invalid.invalid> - 2011-11-21 23:08 +0000
            Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Grant Edwards <invalid@invalid.invalid> - 2011-11-21 23:09 +0000
              Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. Chris Angelico <rosuav@gmail.com> - 2011-11-22 11:32 +1100

Page 2 of 2 — ← Prev page 1 [2]


#16049

FromDavid Riley <fraveydank@gmail.com>
Date2011-11-21 15:42 -0500
Message-ID<mailman.2933.1321908148.27778.python-list@python.org>
In reply to#16046
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) = 0x8F, but (0x8F | 0x80) = 0x8F as well, whereas (0x8F + 0x80) = 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 = 128, which is binary 10000000 (i.e. the high bit in a byte).


- Dave

[toc] | [prev] | [next] | [standalone]


#16053

FromGrant Edwards <invalid@invalid.invalid>
Date2011-11-21 23:08 +0000
Message-ID<jaelks$e20$1@reader1.panix.com>
In reply to#16049
On 2011-11-21, David Riley <fraveydank@gmail.com> wrote:
> 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) = 0x8F, but (0x8F | 0x80) = 0x8F as well, whereas (0x8F + 0x80) = 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 = 128, which is binary 10000000 (i.e. the high bit in a byte).

Like the old joke:

  There are 10 kinds of people in the world: those who understand
  binary numbers, and those who don't.

-- 
Grant Edwards               grant.b.edwards        Yow! ... I don't like FRANK
                                  at               SINATRA or his CHILDREN.
                              gmail.com            

[toc] | [prev] | [next] | [standalone]


#16055

FromGrant Edwards <invalid@invalid.invalid>
Date2011-11-21 23:09 +0000
Message-ID<jaelno$e20$2@reader1.panix.com>
In reply to#16053
On 2011-11-21, Grant Edwards <invalid@invalid.invalid> wrote:

> Like the old joke:
>
>   There are 10 kinds of people in the world: those who understand
>   binary numbers, and those who don't.

OK, it's not _much_ of a joke, but I don't get to use it very often,
so I couldn't let it go (for one thing, it only works in "print").


-- 
Grant Edwards               grant.b.edwards        Yow! I feel like I am
                                  at               sharing a ``CORN-DOG''
                              gmail.com            with NIKITA KHRUSCHEV ...

[toc] | [prev] | [next] | [standalone]


#16060

FromChris Angelico <rosuav@gmail.com>
Date2011-11-22 11:32 +1100
Message-ID<mailman.2938.1321921953.27778.python-list@python.org>
In reply to#16055
On Tue, Nov 22, 2011 at 10:09 AM, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2011-11-21, Grant Edwards <invalid@invalid.invalid> wrote:
>
>> Like the old joke:
>>
>>   There are 10 kinds of people in the world: those who understand
>>   binary numbers, and those who don't.
>
> OK, it's not _much_ of a joke, but I don't get to use it very often,
> so I couldn't let it go (for one thing, it only works in "print").

On a scale of 1 to 10, what is the probability that this is in binary?

There's plenty of great binary jokes going around.

ChrisA

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web