Should SQLite distinguish between +0.0 and -0.0 on output?

classic Classic list List threaded Threaded
67 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: [SPAM?] Re: [EXTERNAL] Re: Should SQLite distinguish between +0.0 and -0.0 on output?

R Smith-2

On 2019/06/14 4:23 AM, Richard Damon wrote:

> On 6/13/19 10:51 AM, R Smith wrote:
>> On 2019/06/13 4:44 PM, Doug Currie wrote:
>>>> Except by the rules of IEEE (as I understand them)
>>>>
>>>> -0.0 < 0.0 is FALSE, so -0.0 is NOT "definitely left of true zero"
>>>>
>>> Except that 0.0 is also an approximation to zero, not "true zero."
>>>
>>> Consider that 1/-0.0 is -inf whereas 1/0.0 is +int
>>
>> I do not know if this is the result case in any of the programming
>> languages, but in Mathematical terms that is just not true.
>>
>> 1/0.0 --> Undefined, doesn't exist, cannot be computed, Should error
>> out. Anything returning +Inf or -Inf is plain wrong.
>> I posit the same holds true for 1/-0.0
> Yes, 1.0/0.0 is undefined in the Field of Real numbers, but IEEE isn't
> the field of Real Numbers. First, as pointed out, it has limited
> precision, but secondly it have values that are not in the field of Real
> Numbers, namely NaN and +/-Inf.
>
> Note, that with a computer, you need to do SOMETHING when asked for
> 1.0/0.0, it isn't good to just stop (and traps/exceptions are hard to
> define for general compution systems), so defining the result is much
> better than just defining that anything could happen. It could have been
> defined as just a NaN, but having a special 'error' value for +Inf or
> -Inf turns out to be very useful in some fields.

I wasn't advocating to do something weird when the value -0.0 exists in
memory - the display of that is what the greater idea behind this thread
is[**].

What I was objecting to, is claiming (in service of suggesting the
use-case for -0.0), that the mathematical result of 1/-0.0 IS in fact
"-Inf" and so computers should conform, when it simply isn't, it's an
error and SHOULD be shown so. Neither is the mathematical result of 0/-1
= -0.0. It simply isn't mathematically true (or rather, it isn't
distinct from 0.0), and I maintain that any system that stores -0.0 as
the result of the computation of 0/-1 is simply doing so by virtue of
the computational method handling the sign-bit separate from the
division and being able to store it like so by happenstance of IEEE754
allowing -0.0 as a distinct value thanks to that same sign bit, and not
because it ever was mathematically necessary to do so.

I'll be happy to eat my words if someone can produce a mathematical
paper that argued for the inclusion of -0.0 in IEEE754 to serve a
mathematical concept. It's a fault, not a feature.


[** As to the greater question of representation - In fact I'm now a bit
on the fence about it. It isn't mathematical, but it does help represent
true bit-data content. I'm happy with it both ways.]



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [SPAM?] Re: [EXTERNAL] Re: Should SQLite distinguish between +0.0 and -0.0 on output?

Doug Currie-2
On Fri, Jun 14, 2019 at 7:16 AM R Smith <[hidden email]> wrote:

>
> What I was objecting to, is claiming (in service of suggesting the
> use-case for -0.0), [...]
>
> I'll be happy to eat my words if someone can produce a mathematical
> paper that argued for the inclusion of -0.0 in IEEE754 to serve a
> mathematical concept. It's a fault, not a feature.
>

David Goldberg's classic paper "What Every Computer Scientist Should Know
About Floating-Point Arithmetic" has a section on this topic, 2.2.3 Slgned
Zero, with a few use cases.

W. Kahan's early papers on standardizing floating point uses the term
"affine mode" to describe when signed zeros and infinities matter (as
opposed to "projective mode").
E.g.,
ON A PROPOSED FLOATING-POINT STANDARD
W. Kahan
University of California, Berkeley
J. Palmer
INTEL Corporation, Aloha, Oregon
October 1, 1979

e
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [SPAM?] Re: [EXTERNAL] Re: Should SQLite distinguish between +0.0 and -0.0 on output?

Thomas Kurz
In reply to this post by R Smith-2
> I'll be happy to eat my words if someone can produce a mathematical
paper that argued for the inclusion of -0.0 in IEEE754 to serve a
mathematical concept. It's a fault, not a feature.

There are indeed very few use cases. The most common one is dealing with water temperature. You can have water at 0 C and ice at 0 C, both states differ only by latent heat. It's one of the rare cases where you could 0 and -0 to distinguish between phases.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: Should SQLite distinguish between +0.0 and -0.0 on output?

Richard Damon
In reply to this post by R Smith-2
On 6/14/19 7:15 AM, R Smith wrote:

>
> On 2019/06/14 4:23 AM, Richard Damon wrote:
>> On 6/13/19 10:51 AM, R Smith wrote:
>>> On 2019/06/13 4:44 PM, Doug Currie wrote:
>>>>> Except by the rules of IEEE (as I understand them)
>>>>>
>>>>> -0.0 < 0.0 is FALSE, so -0.0 is NOT "definitely left of true zero"
>>>>>
>>>> Except that 0.0 is also an approximation to zero, not "true zero."
>>>>
>>>> Consider that 1/-0.0 is -inf whereas 1/0.0 is +int
>>>
>>> I do not know if this is the result case in any of the programming
>>> languages, but in Mathematical terms that is just not true.
>>>
>>> 1/0.0 --> Undefined, doesn't exist, cannot be computed, Should error
>>> out. Anything returning +Inf or -Inf is plain wrong.
>>> I posit the same holds true for 1/-0.0
>> Yes, 1.0/0.0 is undefined in the Field of Real numbers, but IEEE isn't
>> the field of Real Numbers. First, as pointed out, it has limited
>> precision, but secondly it have values that are not in the field of Real
>> Numbers, namely NaN and +/-Inf.
>>
>> Note, that with a computer, you need to do SOMETHING when asked for
>> 1.0/0.0, it isn't good to just stop (and traps/exceptions are hard to
>> define for general compution systems), so defining the result is much
>> better than just defining that anything could happen. It could have been
>> defined as just a NaN, but having a special 'error' value for +Inf or
>> -Inf turns out to be very useful in some fields.
>
> I wasn't advocating to do something weird when the value -0.0 exists
> in memory - the display of that is what the greater idea behind this
> thread is[**].
>
> What I was objecting to, is claiming (in service of suggesting the
> use-case for -0.0), that the mathematical result of 1/-0.0 IS in fact
> "-Inf" and so computers should conform, when it simply isn't, it's an
> error and SHOULD be shown so. Neither is the mathematical result of
> 0/-1 = -0.0. It simply isn't mathematically true (or rather, it isn't
> distinct from 0.0), and I maintain that any system that stores -0.0 as
> the result of the computation of 0/-1 is simply doing so by virtue of
> the computational method handling the sign-bit separate from the
> division and being able to store it like so by happenstance of IEEE754
> allowing -0.0 as a distinct value thanks to that same sign bit, and
> not because it ever was mathematically necessary to do so.
>
> I'll be happy to eat my words if someone can produce a mathematical
> paper that argued for the inclusion of -0.0 in IEEE754 to serve a
> mathematical concept. It's a fault, not a feature.
>
>
> [** As to the greater question of representation - In fact I'm now a
> bit on the fence about it. It isn't mathematical, but it does help
> represent true bit-data content. I'm happy with it both ways.]

I was pointing out that it depends on WHICH type of mathematics you are
talking about what is the proper result of 1/0. If you have your mind
wrapped around the idea the 'Floating Point' == 'Real Numbers', then it
doesn't make sense, but it is a best a rough approximation, expressing
not all of the Reals, but also expressing some things that are outside
the domain of the Reals. A simple example, 1.0 / 3.0 * 3.0 - 1.0 should
be exactly 0.0 in the domain of real numbers. It will NOT be in the
domain of Floating Point numbers (because 1.0 / 3.0 can not be exactly
represented). You can't even say the results will be 'close' to zero, as
there is no expressible tolerance based just on the final expected
answer, as you could replace the 1.0 with a billion, or a billionth, and
get very different values, all of which would need to be considered 'close'.

My understanding is that IEEE COULD have defined 1/0 as NaN instead, but
there were significant areas of numerical calculation where remembering
the infinity, and then using the fact that n / inf is 0 gave meaningful
answers in some cases. (or the atan(inf) = pi/2).

--
Richard Damon

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Should SQLite distinguish between +0.0 and -0.0 on output?

jm cuaz
In reply to this post by Richard Hipp-3
Maybe the core pb under the question asked here is this prior question :

from the standard, is it possible to consider 0.0 as an imprecise
representation of 0 ?

(if yes, signing 0.0 seems logical to me)

Regards,

-jm


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Should SQLite distinguish between +0.0 and -0.0 on output?

Darren Duncan
In reply to this post by Richard Hipp-3
On 2019-06-12 6:35 a.m., Richard Hipp wrote:
> IEEE754 floating point numbers have separate representations for +0.0
> and -0.0.  As currently implemented, SQLite always display both
> quantities as just "0.0".
>
> Question:  Should SQLite be enhanced to show -0.0 as "-0.0"?  Or,
> would that create unnecessary confusion?

I would say, either you support IEEE754 floats fully to the standard, or you
don't pretend to support them and just say you have floats without mentioning
IEEE754.  Also I say that distinguishing -0.0 and 0.0 is good for those that
need to know and harmless to those that don't. -- Darren Duncan
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Should SQLite distinguish between +0.0 and -0.0 on output?

Jens Alfke-2
In reply to this post by Richard Hipp-3


> On Jun 12, 2019, at 8:28 AM, Richard Hipp <[hidden email]> wrote:
>
> That is already the case, and has been for 17 years.  The question at
> hand is what should SQLite do when the application asks it to convert
> a -0.0 value into text.

IMHO, any application code that outsources numeric/text conversions to SQLite must not be serious about numerics. :)

Or in other words, anyone who's far enough down the numerics rabbit-hole to care about the difference between +0.0 and -0.0 is going to want to do the formatting themselves, to make sure that other details like significant figures and rounding are done to their standards.

—Jens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
1234