MATRIX producing a signed zero at saving?

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

MATRIX producing a signed zero at saving?

Kirill Orlov
SPSS (at least vers. 20, 22, 25)  MATRIX session *saves* the result of 0 * (-1)  as -0.

*MATRIX saving two versions of 0.
matrix.
compute x= {1;0}.
compute y= {0;-1}.
compute xy= x &* y.
print xy /format f20.16. /*The two zeros
print (xy(1)=xy(2)). /*They are equal
print (xy=0). /*and are zero
save xy /out= * /var= xy. /*But upon saving out to a dataset...
end matrix.
frequencies xy. /*...there are TWO different zeros in FREQUENCIES!
                  /* click both to find that one is "signed"

*Compare with this normal result.
data list list /x y.
begin data
1 0
0 -1
end data.
compute xy= x * y.
frequencies xy. /*One value, zero

Do you think it is fair?
Reply | Threaded
Open this post in threaded view
|

Re: MATRIX producing a signed zero at saving?

Art Kendall
IFF I recall correctly in the 1970s, CDC computers had several kinds of "dirty zeros".
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: MATRIX producing a signed zero at saving?

Andy W
Fair I don't know about. But yes there are cases where -0 and +0 result in different calculations. See this recent article from Hackernews, https://habr.com/en/post/574082/, One does not simply calculate the absolute value.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: MATRIX producing a signed zero at saving?

jkpeck
In reply to this post by Kirill Orlov
I commented on this on the SPSS-X list, but, sadly, it does not appear on the Nabble version.
Reply | Threaded
Open this post in threaded view
|

Re: MATRIX producing a signed zero at saving?

Kirill Orlov
Jon, could you repeat your answer here or leave the link?
Reply | Threaded
Open this post in threaded view
|

Re: MATRIX producing a signed zero at saving?

Bruce Weaver
Administrator
In reply to this post by jkpeck
I believe this is the SPSSX-L post Jon is referring to.  

--- start of post ---
Date:    Thu, 2 Sep 2021 14:11:35 -0600
From:    Jon Peck
Subject: Re: MATRIX producing a signed zero at saving?

Interesting.

The IEEE floating point standard accommodates a negative zero, but SPSS
Statistics would be following the implementation of the C/C++/Fortran
runtime library.

A negative floating point zero is represented by a zero mantissa and zero
exponent but a 1 sign bit.  Negative and positive zeros compare equal
according to the standard and in SPSS.  If you convert xy to a hex string,
both have the same representation.  I have no idea why FREQUENCIES treats
the values as different, since other parts of Statistics don't, but I don't
see this as having any practical consequences.
--- end of post ---

jkpeck wrote
I commented on this on the SPSS-X list, but, sadly, it does not appear on the Nabble version.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).