Is signed zero always available?
michael.selik at gmail.com
Wed Jun 22 20:34:51 EDT 2016
On Wed, Jun 22, 2016 at 4:53 PM Christopher Reimer <
christopher_reimer at icloud.com> wrote:
> > On Jun 22, 2016, at 7:59 AM, Grant Edwards <grant.b.edwards at gmail.com>
> >> On 2016-06-22, Random832 <random832 at 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?
I can't remember where I came across the concept. It might have been in
calculus. Zero can be thought of as the asymptotic value of 1/n as n
approaches infinity. If so, then negative zero would be the asymptote of
-1/n as n approaches infinity.
More information about the Python-list