Fwd: [Glass] Negative infinity and positive infinity have the same sign

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [Glass] Negative infinity and positive infinity have the same sign

Tobias Pape
Hi all,

it seems, we also suffer from this bug:

{ 0 sign.
 0.0 sign.
-0 sign.
-0.0 sign.
}
"=>  #(0 0 0 -1)"

Begin forwarded message:

> From: Martin McClure via Glass <[hidden email]>
> Subject: Re: [Glass] Negative infinity and positive infinity have the same sign
> Date: 26. Januar 2017 21:10:32 MEZ
> To: monty <[hidden email]>, [hidden email]
> Reply-To: Martin McClure <[hidden email]>
> Delivered-To: [hidden email]
>
> On 01/25/2017 12:45 PM, monty via Glass wrote:
>> On 3.3.0, "-0.0 sign = 0.0 sign". On Pharo, "-1 sign = -1", "-0.0 sign = -1", "0.0 sign = 0", and "1 sign = 1". IEEE Standard 754 mandates that negative zero have the same sign bit as a negative number.
>> _______________________________________________
> Hi Monty,
>
> The ANSI Smalltalk standard says that #sign should answer 0 if "the
> receiver equals zero". This agrees with ISO/IEC 10967 Portable Numerics
> standard, which says the same thing. The IEEE 754 spec does not specify
> a "sign" operation. The closest equivalent I see is the "isSignMinus"
> operation. We don't currently have that message in GemStone, but we
> might add it. In GemStone, you can distinguish positive and negative
> zero by sending #_sign.
>
> Pharo's implementation seems very odd. It looks like it's been that way
> a long time (John Maloney in 1998?) but the comment contradicts itself.
> It says
> "Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0.
>    Handle IEEE-754 negative-zero by reporting a sign of -1"
>
> But negative zero *is* equal to 0, so it claims to be answering both 0
> and -1 for -0.0. Leaving that aside, it's disturbingly asymmetric to
> answer 0 for 0.0 but -1 for -0.0.
>
> Regards,
>
> -Martin
> _______________________________________________
> Glass mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/glass


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [Glass] Negative infinity and positive infinity have the same sign

Tobias Pape
Hi

On 27.01.2017, at 08:37, Tobias Pape <[hidden email]> wrote:

> Hi all,
>
> it seems, we also suffer from this bug:
>
> { 0 sign.
> 0.0 sign.
> -0 sign.
> -0.0 sign.
> }
> "=>  #(0 0 0 -1)"

PS: why bug?
IEEE-754 says that 0.0 and -0.0 are equal and equal numbers have same sign,
but for us

        (0.0 = -0.0) ==> (0.0 sign = -0.0 sign)

is false, while it should be true.


>
> Begin forwarded message:
>
>> From: Martin McClure via Glass <[hidden email]>
>> Subject: Re: [Glass] Negative infinity and positive infinity have the same sign
>> Date: 26. Januar 2017 21:10:32 MEZ
>> To: monty <[hidden email]>, [hidden email]
>> Reply-To: Martin McClure <[hidden email]>
>> Delivered-To: [hidden email]
>>
>> On 01/25/2017 12:45 PM, monty via Glass wrote:
>>> On 3.3.0, "-0.0 sign = 0.0 sign". On Pharo, "-1 sign = -1", "-0.0 sign = -1", "0.0 sign = 0", and "1 sign = 1". IEEE Standard 754 mandates that negative zero have the same sign bit as a negative number.
>>> _______________________________________________
>> Hi Monty,
>>
>> The ANSI Smalltalk standard says that #sign should answer 0 if "the
>> receiver equals zero". This agrees with ISO/IEC 10967 Portable Numerics
>> standard, which says the same thing. The IEEE 754 spec does not specify
>> a "sign" operation. The closest equivalent I see is the "isSignMinus"
>> operation. We don't currently have that message in GemStone, but we
>> might add it. In GemStone, you can distinguish positive and negative
>> zero by sending #_sign.
>>
>> Pharo's implementation seems very odd. It looks like it's been that way
>> a long time (John Maloney in 1998?) but the comment contradicts itself.
>> It says
>> "Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0.
>>   Handle IEEE-754 negative-zero by reporting a sign of -1"
>>
>> But negative zero *is* equal to 0, so it claims to be answering both 0
>> and -1 for -0.0. Leaving that aside, it's disturbingly asymmetric to
>> answer 0 for 0.0 but -1 for -0.0.
>>
>> Regards,
>>
>> -Martin
>> _______________________________________________
>> Glass mailing list
>> [hidden email]
>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [Glass] Negative infinity and positive infinity have the same sign

Nicolas Cellier
Mind the title, it's positive zero, not infinity :)


2017-01-27 8:42 GMT+01:00 <[hidden email]>:
Hi

On 27.01.2017, at 08:37, Tobias Pape <[hidden email]> wrote:

> Hi all,
>
> it seems, we also suffer from this bug:
>
> { 0 sign.
> 0.0 sign.
> -0 sign.
> -0.0 sign.
> }
> "=>  #(0 0 0 -1)"

PS: why bug?

It's a bug because it is against ANSI smalltalk, and because it creates small incompatibilities with gemstone unecessarily.
I have a patch ready for squeak.

IEEE-754 says that 0.0 and -0.0 are equal and equal numbers have same sign,
but for us

        (0.0 = -0.0) ==> (0.0 sign = -0.0 sign)

is false, while it should be true.


More exactly, the logic is rather: the sign of zero is zero.
Float negativeZero value cannot be distinguished from zero, so it is zero, and sign should be zero.

But we can still have another message like signBit immune to this logic.

>
> Begin forwarded message:
>
>> From: Martin McClure via Glass <[hidden email]>
>> Subject: Re: [Glass] Negative infinity and positive infinity have the same sign
>> Date: 26. Januar 2017 21:10:32 MEZ
>> To: monty <[hidden email]>, [hidden email]
>> Reply-To: Martin McClure <[hidden email]>
>> Delivered-To: [hidden email]
>>
>> On 01/25/2017 12:45 PM, monty via Glass wrote:
>>> On 3.3.0, "-0.0 sign = 0.0 sign". On Pharo, "-1 sign = -1", "-0.0 sign = -1", "0.0 sign = 0", and "1 sign = 1". IEEE Standard 754 mandates that negative zero have the same sign bit as a negative number.
>>> _______________________________________________
>> Hi Monty,
>>
>> The ANSI Smalltalk standard says that #sign should answer 0 if "the
>> receiver equals zero". This agrees with ISO/IEC 10967 Portable Numerics
>> standard, which says the same thing. The IEEE 754 spec does not specify
>> a "sign" operation. The closest equivalent I see is the "isSignMinus"
>> operation. We don't currently have that message in GemStone, but we
>> might add it. In GemStone, you can distinguish positive and negative
>> zero by sending #_sign.
>>
>> Pharo's implementation seems very odd. It looks like it's been that way
>> a long time (John Maloney in 1998?) but the comment contradicts itself.
>> It says
>> "Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0.
>>   Handle IEEE-754 negative-zero by reporting a sign of -1"
>>
>> But negative zero *is* equal to 0, so it claims to be answering both 0
>> and -1 for -0.0. Leaving that aside, it's disturbingly asymmetric to
>> answer 0 for 0.0 but -1 for -0.0.
>>
>> Regards,
>>
>> -Martin
>> _______________________________________________
>> Glass mailing list
>> [hidden email]
>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>
>





Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [Glass] Negative infinity and positive infinity have the same sign

David T. Lewis
In reply to this post by Tobias Pape
So this should be added as a failing test in FloatTest?

Dave

On Fri, Jan 27, 2017 at 08:42:15AM +0100, [hidden email] wrote:

> Hi
>
> On 27.01.2017, at 08:37, Tobias Pape <[hidden email]> wrote:
>
> > Hi all,
> >
> > it seems, we also suffer from this bug:
> >
> > { 0 sign.
> > 0.0 sign.
> > -0 sign.
> > -0.0 sign.
> > }
> > "=>  #(0 0 0 -1)"
>
> PS: why bug?
> IEEE-754 says that 0.0 and -0.0 are equal and equal numbers have same sign,
> but for us
>
> (0.0 = -0.0) ==> (0.0 sign = -0.0 sign)
>
> is false, while it should be true.
>
>
> >
> > Begin forwarded message:
> >
> >> From: Martin McClure via Glass <[hidden email]>
> >> Subject: Re: [Glass] Negative infinity and positive infinity have the same sign
> >> Date: 26. Januar 2017 21:10:32 MEZ
> >> To: monty <[hidden email]>, [hidden email]
> >> Reply-To: Martin McClure <[hidden email]>
> >> Delivered-To: [hidden email]
> >>
> >> On 01/25/2017 12:45 PM, monty via Glass wrote:
> >>> On 3.3.0, "-0.0 sign = 0.0 sign". On Pharo, "-1 sign = -1", "-0.0 sign = -1", "0.0 sign = 0", and "1 sign = 1". IEEE Standard 754 mandates that negative zero have the same sign bit as a negative number.
> >>> _______________________________________________
> >> Hi Monty,
> >>
> >> The ANSI Smalltalk standard says that #sign should answer 0 if "the
> >> receiver equals zero". This agrees with ISO/IEC 10967 Portable Numerics
> >> standard, which says the same thing. The IEEE 754 spec does not specify
> >> a "sign" operation. The closest equivalent I see is the "isSignMinus"
> >> operation. We don't currently have that message in GemStone, but we
> >> might add it. In GemStone, you can distinguish positive and negative
> >> zero by sending #_sign.
> >>
> >> Pharo's implementation seems very odd. It looks like it's been that way
> >> a long time (John Maloney in 1998?) but the comment contradicts itself.
> >> It says
> >> "Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0.
> >>   Handle IEEE-754 negative-zero by reporting a sign of -1"
> >>
> >> But negative zero *is* equal to 0, so it claims to be answering both 0
> >> and -1 for -0.0. Leaving that aside, it's disturbingly asymmetric to
> >> answer 0 for 0.0 but -1 for -0.0.
> >>
> >> Regards,
> >>
> >> -Martin
> >> _______________________________________________
> >> Glass mailing list
> >> [hidden email]
> >> http://lists.gemtalksystems.com/mailman/listinfo/glass
> >
> >
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [Glass] Negative infinity and positive infinity have the same sign

Bert Freudenberg
Be sure to fix Float printing of negative zero. I guess this is the only reason it was implemented this way.

- Bert -

On Fri, Jan 27, 2017 at 2:11 PM, David T. Lewis <[hidden email]> wrote:
So this should be added as a failing test in FloatTest?

Dave

On Fri, Jan 27, 2017 at 08:42:15AM +0100, [hidden email] wrote:
> Hi
>
> On 27.01.2017, at 08:37, Tobias Pape <[hidden email]> wrote:
>
> > Hi all,
> >
> > it seems, we also suffer from this bug:
> >
> > { 0 sign.
> > 0.0 sign.
> > -0 sign.
> > -0.0 sign.
> > }
> > "=>  #(0 0 0 -1)"
>
> PS: why bug?
> IEEE-754 says that 0.0 and -0.0 are equal and equal numbers have same sign,
> but for us
>
>       (0.0 = -0.0) ==> (0.0 sign = -0.0 sign)
>
> is false, while it should be true.
>
>
> >
> > Begin forwarded message:
> >
> >> From: Martin McClure via Glass <[hidden email]>
> >> Subject: Re: [Glass] Negative infinity and positive infinity have the same sign
> >> Date: 26. Januar 2017 21:10:32 MEZ
> >> To: monty <[hidden email]>, [hidden email]
> >> Reply-To: Martin McClure <[hidden email]>
> >> Delivered-To: [hidden email]
> >>
> >> On 01/25/2017 12:45 PM, monty via Glass wrote:
> >>> On 3.3.0, "-0.0 sign = 0.0 sign". On Pharo, "-1 sign = -1", "-0.0 sign = -1", "0.0 sign = 0", and "1 sign = 1". IEEE Standard 754 mandates that negative zero have the same sign bit as a negative number.
> >>> _______________________________________________
> >> Hi Monty,
> >>
> >> The ANSI Smalltalk standard says that #sign should answer 0 if "the
> >> receiver equals zero". This agrees with ISO/IEC 10967 Portable Numerics
> >> standard, which says the same thing. The IEEE 754 spec does not specify
> >> a "sign" operation. The closest equivalent I see is the "isSignMinus"
> >> operation. We don't currently have that message in GemStone, but we
> >> might add it. In GemStone, you can distinguish positive and negative
> >> zero by sending #_sign.
> >>
> >> Pharo's implementation seems very odd. It looks like it's been that way
> >> a long time (John Maloney in 1998?) but the comment contradicts itself.
> >> It says
> >> "Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0.
> >>   Handle IEEE-754 negative-zero by reporting a sign of -1"
> >>
> >> But negative zero *is* equal to 0, so it claims to be answering both 0
> >> and -1 for -0.0. Leaving that aside, it's disturbingly asymmetric to
> >> answer 0 for 0.0 but -1 for -0.0.
> >>
> >> Regards,
> >>
> >> -Martin
> >> _______________________________________________
> >> Glass mailing list
> >> [hidden email]
> >> http://lists.gemtalksystems.com/mailman/listinfo/glass
> >
> >
>
>