Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #110352
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Grant Edwards <grant.b.edwards@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Is signed zero always available? |
| Date | Thu, 23 Jun 2016 02:48:52 +0000 (UTC) |
| Lines | 49 |
| Message-ID | <mailman.54.1466650156.11516.python-list@python.org> (permalink) |
| References | <576a925f$0$1597$c3e8da3$5496439d@news.astraweb.com> <nke6pk$fjm$1@ger.gmane.org> <1466606088.4117582.645299713.03DA7658@webmail.messagingengine.com> <nke953$81t$1@ger.gmane.org> <285A7071-5102-4516-BD3E-79C291023705@icloud.com> <nkfimk$bo1$1@ger.gmane.org> |
| X-Trace | news.uni-berlin.de 5080V/mBUiLYqlH7rpWp2wMP47ANqxpCH0gSwc+6JZdg== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'compiler': 0.05; 'used.': 0.05; '22,': 0.09; 'integers': 0.09; 'minus': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'reliably': 0.09; 'zero.': 0.09; 'python': 0.10; 'missed': 0.15; 'wed,': 0.15; 'languages,': 0.15; 'mathematics': 0.15; '-0.': 0.16; 'assembly,': 0.16; 'distinction': 0.16; 'integers.': 0.16; 'mathematics.': 0.16; 'postive': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'trap': 0.16; 'true:': 0.16; 'wrote:': 0.16; 'detect': 0.18; '>>>': 0.20; 'machine': 0.21; 'pascal': 0.22; 'programming': 0.22; 'am,': 0.23; 'discussion': 0.24; 'signed': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'supported': 0.27; 'define': 0.27; 'not.': 0.27; 'cpu': 0.29; 'that.': 0.30; "we're": 0.30; 'probably': 0.31; 'int': 0.33; 'received:comcast.net': 0.33; 'instance': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:org': 0.37; 'available.': 0.37; 'seem': 0.37; 'version': 0.38; 'architecture': 0.38; 'build': 0.40; 'to:addr:python.org': 0.40; 'ever': 0.60; 'back': 0.62; 'more': 0.63; 'complement': 0.66; 'rare': 0.66; 'received:50': 0.66; 'talking': 0.67; 'guaranteed': 0.67; 'computers': 0.70; 'gotten': 0.76; 'miss': 0.77; 'subject:available': 0.79; 'college,': 0.84; 'courses,': 0.84; 'subject:always': 0.84; 'edwards': 0.91; 'chapters': 0.93; 'instructors': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | c-50-188-49-188.hsd1.mn.comcast.net |
| User-Agent | slrn/1.0.2 (Linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <nkfimk$bo1$1@ger.gmane.org> |
| X-Mailman-Original-References | <576a925f$0$1597$c3e8da3$5496439d@news.astraweb.com> <nke6pk$fjm$1@ger.gmane.org> <1466606088.4117582.645299713.03DA7658@webmail.messagingengine.com> <nke953$81t$1@ger.gmane.org> <285A7071-5102-4516-BD3E-79C291023705@icloud.com> |
| Xref | csiph.com comp.lang.python:110352 |
Show key headers only | View raw
On 2016-06-22, Christopher Reimer <christopher_reimer@icloud.com> wrote: >> On Jun 22, 2016, at 7:59 AM, Grant Edwards <grant.b.edwards@gmail.com> wrote: >> >>> On 2016-06-22, Random832 <random832@fastmail.com> wrote: >>>> On Wed, Jun 22, 2016, at 10:19, Grant Edwards wrote: >>>> >>>> Is that guaranteed by Python, or just a side-effect of the >>>> implementation? Back in the days when Python used native C >>>> integers I think the latter. >>> >>> AIUI, native C integers have never reliably supported signed zero >>> even with representations that naively seem to have it. There's no >>> well-defined way to detect it - no int version of copysign, for >>> instance - and implementations are free to erase the distinction on >>> every load/store or define one of them to be a trap representation. >> >> It's been almost 25 years since I used hardware that supported signed >> zero integers (CDC 6600). I don't recall there being a C compiler >> available. We used Pascal and assembly, though I think FORTRAN was >> what most people used. I don't recall whether the Pascal >> implementation exposed the existence of -0 to the user or not. > > When I took mathematics in college, the following was true: > > -1 * 0 = 0 Well, we're talking about computers and programming languages, not mathematics. > I would probably have gotten rapped on the knuckles by my instructors > if I answered -0. Zero was zero. No plus or minus about that. No > discussion of signed integers ever mentioned signed zero. > > Did I miss something in college? If you took computer architecture courses, then yes, you missed the chapters on machine representation of integers. If you build a CPU that uses either 1's compliment or signed magnitude representations then there is a postive zero and a negative zero. If you design it to use 2's complement, then there is only a positive zero. 1's complement and signed-magnitude are excedingly rare these days, but used to be much more common. -- Grant
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Is signed zero always available? Steven D'Aprano <steve@pearwood.info> - 2016-06-22 23:27 +1000
Re: Is signed zero always available? Grant Edwards <grant.b.edwards@gmail.com> - 2016-06-22 14:19 +0000
Re: Is signed zero always available? Random832 <random832@fastmail.com> - 2016-06-22 10:34 -0400
Re: Is signed zero always available? Grant Edwards <grant.b.edwards@gmail.com> - 2016-06-22 14:59 +0000
Re: Is signed zero always available? Christopher Reimer <christopher_reimer@icloud.com> - 2016-06-22 15:50 -0700
Re: Is signed zero always available? Steven D'Aprano <steve@pearwood.info> - 2016-06-23 11:16 +1000
Re: Is signed zero always available? Michael Selik <michael.selik@gmail.com> - 2016-06-23 00:34 +0000
Re: Is signed zero always available? Grant Edwards <grant.b.edwards@gmail.com> - 2016-06-23 02:48 +0000
csiph-web