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


Groups > comp.lang.python > #110346

Re: Is signed zero always available?

From Christopher Reimer <christopher_reimer@icloud.com>
Newsgroups comp.lang.python
Subject Re: Is signed zero always available?
Date 2016-06-22 15:50 -0700
Message-ID <mailman.52.1466639498.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>

Show all headers | View raw


> 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

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?

Or did -0 represent zero volts on the negative rail of an op-amp in electronics? 

Thank you,

Chris R.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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