SPSS 17: wrong result computing 3 * 0.7

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

SPSS 17: wrong result computing 3 * 0.7

Hannes Schreier
Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS 17
delivers 2.0999999999999996. Not much difference, but from such an expensive
software package you should expect no difference at all! Hope this is fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Roberts, Michael
Maybe your system is older (?)  I created a variable with the same
syntax and get 2.1(?) - using a dell Optiplex gx620, 3.2ghz,2gb Ram,
etc.  Perhaps you could try on another machine and see what results you
get?

HTH

mike

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Lemon, John S.
Surely this is just rounding which happens all the time with computers - in the good old days there was much discussion about this but when I was taught arithmetic ( with log tables and slide rules ) we always understood 2.099999999999999 was the same as 2.1 !!!


Best Wishes

John S. Lemon
DIT ( Directorate of Information Technology ) - Student Liaison Officer
University of Aberdeen
Edward Wright Building: Room G51

Tel:  +44 1224 273350
Fax: +44 1224 273372


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Roberts, Michael
Sent: 13 November 2008 14:10
To: [hidden email]
Subject: Re: SPSS 17: wrong result computing 3 * 0.7

Maybe your system is older (?)  I created a variable with the same
syntax and get 2.1(?) - using a dell Optiplex gx620, 3.2ghz,2gb Ram,
etc.  Perhaps you could try on another machine and see what results you
get?

HTH

mike

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


The University of Aberdeen is a charity registered in Scotland, No SC013683.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Roberts, Michael
In reply to this post by Hannes Schreier
Correction - the display shows 2.1 but it appears rounded up - I checked
with 0s to the 16th decimal, so Hannes appears to be correct.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

ViAnn Beadle
Data are stored as floating point binary within SPSS and there is always a
bit of fuzz between decimal and binary numbers.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Roberts, Michael
Sent: Thursday, November 13, 2008 7:17 AM
To: [hidden email]
Subject: Re: SPSS 17: wrong result computing 3 * 0.7

Correction - the display shows 2.1 but it appears rounded up - I checked
with 0s to the 16th decimal, so Hannes appears to be correct.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Baker, Harley
In reply to this post by Lemon, John S.
I think the anomalous result must be machine-dependent as Mike suggested.
I just did the same calculations: (3)(.7) and got 2.1. I am using v17 on a
new iMac. I reran it after rebooting as a Vista machine using Bootstrap and
got 2.1 again.

Harley

Dr. Harley Baker
Associate Professor and Chair, Psychology Program
California State University Channel Islands
One University Drive
Camarillo, CA 93012

805.437.8997 (p)
805.437.8951 (f)

[hidden email]



> From: "Lemon, John S." <[hidden email]>
> Reply-To: "Lemon, John S." <[hidden email]>
> Date: Thu, 13 Nov 2008 14:13:36 +0000
> To: <[hidden email]>
> Conversation: SPSS 17: wrong result computing 3 * 0.7
> Subject: Re: SPSS 17: wrong result computing 3 * 0.7
>
> Surely this is just rounding which happens all the time with computers - in
> the good old days there was much discussion about this but when I was taught
> arithmetic ( with log tables and slide rules ) we always understood
> 2.099999999999999 was the same as 2.1 !!!
>
>
> Best Wishes
>
> John S. Lemon
> DIT ( Directorate of Information Technology ) - Student Liaison Officer
> University of Aberdeen
> Edward Wright Building: Room G51
>
> Tel:  +44 1224 273350
> Fax: +44 1224 273372
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Roberts, Michael
> Sent: 13 November 2008 14:10
> To: [hidden email]
> Subject: Re: SPSS 17: wrong result computing 3 * 0.7
>
> Maybe your system is older (?)  I created a variable with the same
> syntax and get 2.1(?) - using a dell Optiplex gx620, 3.2ghz,2gb Ram,
> etc.  Perhaps you could try on another machine and see what results you
> get?
>
> HTH
>
> mike
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Hannes Schreier
> Sent: Thursday, November 13, 2008 8:56 AM
> To: [hidden email]
> Subject: SPSS 17: wrong result computing 3 * 0.7
>
> Hi all,
>
> when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
> 17
> delivers 2.0999999999999996. Not much difference, but from such an
> expensive
> software package you should expect no difference at all! Hope this is
> fixed
> with the upcoming update...
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
>
> The University of Aberdeen is a charity registered in Scotland, No SC013683.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Baker, Harley
In reply to this post by Roberts, Michael
I too set the formats to f20.16 and got 2.999999999 . . . .6.

Oh well . . .

Harley


Dr. Harley Baker
Associate Professor and Chair, Psychology Program
California State University Channel Islands
One University Drive
Camarillo, CA 93012

805.437.8997 (p)
805.437.8951 (f)

[hidden email]



> From: "Roberts, Michael" <[hidden email]>
> Reply-To: "Roberts, Michael" <[hidden email]>
> Date: Thu, 13 Nov 2008 09:17:17 -0500
> To: <[hidden email]>
> Conversation: SPSS 17: wrong result computing 3 * 0.7
> Subject: Re: SPSS 17: wrong result computing 3 * 0.7
>
> Correction - the display shows 2.1 but it appears rounded up - I checked
> with 0s to the 16th decimal, so Hannes appears to be correct.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Hannes Schreier
> Sent: Thursday, November 13, 2008 8:56 AM
> To: [hidden email]
> Subject: SPSS 17: wrong result computing 3 * 0.7
>
> Hi all,
>
> when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
> 17
> delivers 2.0999999999999996. Not much difference, but from such an
> expensive
> software package you should expect no difference at all! Hope this is
> fixed
> with the upcoming update...
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Peck, Jon
In reply to this post by Roberts, Michael
Bear in mind that this is the nature of floating point hardware.  0.7 does not have an exact representation in floating point, so this is as close as the hardware can get.  What has changed in subtle ways over various SPSS version is exactly how the result is rounded for display purposes.  New in version 17 are parameters to the rnd function that give you greater control over the gory details of how that function works.  It may give some insight into the characteristics of floating point arithmetic hardware.  Most users will never need these parameters, but here is the help for the RND.  The TRUNC function has similar new parameters.

RND. RND(numexpr[,mult,fuzzbits]). Numeric. With a single argument, returns the integer nearest to that argument. Numbers ending in .5 exactly are rounded away from 0. For example, RND(-4.5) rounds to -5. The optional second argument, mult, specifies that the result is an integer multiple of this value-for example, RND(-4.57,0.1) = -4.6. The value must be numeric but cannot be 0. The default is 1.

The optional third argument, fuzzbits, is the number of least-significant bits by which the internal representation of numexpr (expressed as a 64-bit floating point binary) may fall short of the threshold for rounding up (e.g., 0.5 when rounding to an integer) but still be rounded up. For example, the sum 9.62 - 5.82 - 9.21 + 6.91 has an internal representation of 1.499999999999998 (on an Intel processor). With fuzzbits set to 0 and mult set to 1, this expression will round to 1.0, although the exact sum is 1.50 which would round to 2.0. Allowing the rounding threshold to have a small fuzziness compensates for the minute differences between calculations with floating point numbers and exact results. In this case, adding a fuzziness of 4 bits is sufficient to produce the expected result of 2.0.

If the argument fuzzbits is omitted, the value specified by SET FUZZBITS is used. The installed setting of FUZZBITS is 6, which should be sufficient for most applications. Setting fuzzbits to 0 produces the same results as in release 10. Setting fuzzbits to 10 produces the same results as in releases 11 and 12.

To produce the same results as in release 13, use the following expression in place of the RND function:

TRUNC(numexpr,1,0) + ((.5+TRUNC(numexpr,1,0)-numexpr)<max(1e-13,min(.5,numexpr*1e-13)))
To produce the same results as in releases 14, 15, and 16 use:

RND(numexpr,1,12.5-ln(max(1e-50,abs(numexpr)))/ln(2))

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Roberts, Michael
Sent: Thursday, November 13, 2008 7:17 AM
To: [hidden email]
Subject: Re: [SPSSX-L] SPSS 17: wrong result computing 3 * 0.7

Correction - the display shows 2.1 but it appears rounded up - I checked
with 0s to the 16th decimal, so Hannes appears to be correct.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Roberts, Michael
In reply to this post by Hannes Schreier
I have just rerun some computations and noted that you have to use the
rounding function in the computation including the fuzzbits
specification set to 0.  This results in the required 2.1 result instead
of only the 2.0999999999996, etc.

mike

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Roberts, Michael
In reply to this post by Hannes Schreier
Here is the calc that works (You can also get the same result if you
omit the first arguments '.1'.):

compute test6=rnd(3,.1,0)*rnd(.7,.1,0).
exe.

mike

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Granaas, Michael
In reply to this post by ViAnn Beadle
 ViAnn Beadle said:
 
"Data are stored as floating point binary within SPSS and there is always a
bit of fuzz between decimal and binary numbers."

to which I reply:

True.

If you display enough decimal points any decimal that does not convert exactly to binary will contains some bit of rounding error.  This was true with the earliest computers and it will remain true until we develop computers that do native decimal arithmetic.  

I feel certain that there must be ways to correct for this in the software, but I am not losing any sleep over it.

Michael

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Roberts, Michael
Sent: Thursday, November 13, 2008 7:17 AM
To: [hidden email]
Subject: Re: SPSS 17: wrong result computing 3 * 0.7

Correction - the display shows 2.1 but it appears rounded up - I checked
with 0s to the 16th decimal, so Hannes appears to be correct.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Hannes Schreier
Sent: Thursday, November 13, 2008 8:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17
delivers 2.0999999999999996. Not much difference, but from such an
expensive
software package you should expect no difference at all! Hope this is
fixed
with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

====================To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Art Kendall
In reply to this post by Hannes Schreier
Are you sure that you have the same display format set?

Please try something like this on each setup.
compute mynumber = 3*.7.
formats mynumber (f20.16) .
list variables = mynumber.
formats mynumber (f5.1).
list variables = mynumber.
Please let us know what you find.

Art Kendall
Social Research Consultants

Hannes Schreier wrote:

> Hi all,
>
> when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS 17
> delivers 2.0999999999999996. Not much difference, but from such an expensive
> software package you should expect no difference at all! Hope this is fixed
> with the upcoming update...
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

AW: SPSS 17: wrong result computing 3 * 0.7

Hannes Schreier
In reply to this post by Hannes Schreier
Hi,

These are the results when I run Arts sytax:

compute mynumber = 3*.7.
formats mynumber (f20.16) .
list variables = mynumber.

            mynumber

  2,0999999999999990

formats mynumber (f5.1).
list variables = mynumber.


mynumber

    2,1

Changing the format rounds the result, but the wrong raw-value will be used in further computations . So if a simple compute command deliviers a wrong result, how much can we trust more complex analysis?


Hannes Schreier

_____________________________________

Institut Schreier
Umfragen und Analysen

Postanschrift:
Postfach 25 71
72015 Tübingen

Hausanschrift:
Schweickhardtstr. 1
72072 Tübingen

Fon: 07071/538016
Fax: 07071/538015
www.institut-schreier.de




-----Ursprüngliche Nachricht-----
Von: Art Kendall [mailto:[hidden email]]
Gesendet: Donnerstag, 13. November 2008 19:31
An: Hannes Schreier
Cc: [hidden email]
Betreff: Re: SPSS 17: wrong result computing 3 * 0.7

Are you sure that you have the same display format set?

Please try something like this on each setup.
compute mynumber = 3*.7.
formats mynumber (f20.16) .
list variables = mynumber.
formats mynumber (f5.1).
list variables = mynumber.
Please let us know what you find.

Art Kendall
Social Research Consultants

Hannes Schreier wrote:

> Hi all,
>
> when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1.
> SPSS 17 delivers 2.0999999999999996. Not much difference, but from
> such an expensive software package you should expect no difference at
> all! Hope this is fixed with the upcoming update...
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except
> the command. To leave the list, send the command SIGNOFF SPSSX-L For a
> list of commands to manage subscriptions, send the command INFO
> REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: AW: SPSS 17: wrong result computing 3 * 0.7

Art Kendall
try GOOGLEing "floating point"

Art Kendall

Hannes Schreier wrote:

> Hi,
>
> These are the results when I run Arts sytax:
>
> compute mynumber = 3*.7.
> formats mynumber (f20.16) .
> list variables = mynumber.
>
>             mynumber
>
>   2,0999999999999990
>
> formats mynumber (f5.1).
> list variables = mynumber.
>
>
> mynumber
>
>     2,1
>
> Changing the format rounds the result, but the wrong raw-value will be used in further computations . So if a simple compute command deliviers a wrong result, how much can we trust more complex analysis?
>
>
> Hannes Schreier
>
> _____________________________________
>
> Institut Schreier
> Umfragen und Analysen
>
> Postanschrift:
> Postfach 25 71
> 72015 Tübingen
>
> Hausanschrift:
> Schweickhardtstr. 1
> 72072 Tübingen
>
> Fon: 07071/538016
> Fax: 07071/538015
> www.institut-schreier.de
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Art Kendall [mailto:[hidden email]]
> Gesendet: Donnerstag, 13. November 2008 19:31
> An: Hannes Schreier
> Cc: [hidden email]
> Betreff: Re: SPSS 17: wrong result computing 3 * 0.7
>
> Are you sure that you have the same display format set?
>
> Please try something like this on each setup.
> compute mynumber = 3*.7.
> formats mynumber (f20.16) .
> list variables = mynumber.
> formats mynumber (f5.1).
> list variables = mynumber.
> Please let us know what you find.
>
> Art Kendall
> Social Research Consultants
>
> Hannes Schreier wrote:
>
>> Hi all,
>>
>> when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1.
>> SPSS 17 delivers 2.0999999999999996. Not much difference, but from
>> such an expensive software package you should expect no difference at
>> all! Hope this is fixed with the upcoming update...
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>> [hidden email] (not to SPSSX-L), with no body text except
>> the command. To leave the list, send the command SIGNOFF SPSSX-L For a
>> list of commands to manage subscriptions, send the command INFO
>> REFCARD
>>
>>
>>
>>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: AW: SPSS 17: wrong result computing 3 * 0.7

Roberts, Michael
In reply to this post by Hannes Schreier
As Jon Peck pointed out, using rounding with fuzzbit specified resolves this issue.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hannes Schreier
Sent: Thursday, November 13, 2008 4:46 PM
To: [hidden email]
Subject: AW: SPSS 17: wrong result computing 3 * 0.7

Hi,

These are the results when I run Arts sytax:

compute mynumber = 3*.7.
formats mynumber (f20.16) .
list variables = mynumber.

            mynumber

  2,0999999999999990

formats mynumber (f5.1).
list variables = mynumber.


mynumber

    2,1

Changing the format rounds the result, but the wrong raw-value will be used in further computations . So if a simple compute command deliviers a wrong result, how much can we trust more complex analysis?


Hannes Schreier

_____________________________________

Institut Schreier
Umfragen und Analysen

Postanschrift:
Postfach 25 71
72015 Tübingen

Hausanschrift:
Schweickhardtstr. 1
72072 Tübingen

Fon: 07071/538016
Fax: 07071/538015
www.institut-schreier.de




-----Ursprüngliche Nachricht-----
Von: Art Kendall [mailto:[hidden email]]
Gesendet: Donnerstag, 13. November 2008 19:31
An: Hannes Schreier
Cc: [hidden email]
Betreff: Re: SPSS 17: wrong result computing 3 * 0.7

Are you sure that you have the same display format set?

Please try something like this on each setup.
compute mynumber = 3*.7.
formats mynumber (f20.16) .
list variables = mynumber.
formats mynumber (f5.1).
list variables = mynumber.
Please let us know what you find.

Art Kendall
Social Research Consultants

Hannes Schreier wrote:

> Hi all,
>
> when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1.
> SPSS 17 delivers 2.0999999999999996. Not much difference, but from
> such an expensive software package you should expect no difference at
> all! Hope this is fixed with the upcoming update...
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except
> the command. To leave the list, send the command SIGNOFF SPSSX-L For a
> list of commands to manage subscriptions, send the command INFO
> REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Arthur Burke
In reply to this post by Hannes Schreier
Hannes ... Maybe SPSS is smarter than you think:

data list /x (f3.1).
begin data
2.1
2.1
end data.
compute y=3*0.7.
compute z=x-y.
execute.

Art
----------------------------------------------------
Art Burke
Northwest Regional Educational Laboratory
101 SW Main St, Suite 500
Portland, OR 97204-3213


-----Original Message-----
From: Hannes Schreier [mailto:[hidden email]]
Sent: Thursday, November 13, 2008 5:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17 delivers 2.0999999999999996. Not much difference, but from such an
expensive software package you should expect no difference at all! Hope
this is fixed with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Fry, Jonathan B.
This is actually fixed in an upcoming patch, and it's much less than it appears.

In binary floating-point numbers (the computer representation used in all releases of SPSS since 1980), there is no exact representation for 2.1, for the same reason there is no exact representation for 1/3 in decimal.  It's a non-terminating binary number.  You're getting the same binary number in release 17 as you got in release 15, which is the binary floating-point number closest to 2.1.

The trouble you saw was that the data editor was trying to use too much precision in showing you the number.  If it used one less significant digit, as it did in 15, you would just see 2.1.

Jonathan Fry
SPSS Inc.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Arthur Burke
Sent: Thursday, November 13, 2008 4:31 PM
To: [hidden email]
Subject: Re: SPSS 17: wrong result computing 3 * 0.7

Hannes ... Maybe SPSS is smarter than you think:

data list /x (f3.1).
begin data
2.1
2.1
end data.
compute y=3*0.7.
compute z=x-y.
execute.

Art
----------------------------------------------------
Art Burke
Northwest Regional Educational Laboratory
101 SW Main St, Suite 500
Portland, OR 97204-3213


-----Original Message-----
From: Hannes Schreier [mailto:[hidden email]]
Sent: Thursday, November 13, 2008 5:56 AM
To: [hidden email]
Subject: SPSS 17: wrong result computing 3 * 0.7

Hi all,

when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1. SPSS
17 delivers 2.0999999999999996. Not much difference, but from such an
expensive software package you should expect no difference at all! Hope
this is fixed with the upcoming update...

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Richard Ristow
In reply to this post by Granaas, Michael
At 09:49 AM 11/13/2008, Granaas, Michael wrote:

>  ViAnn Beadle said:
>
>>"Data are stored as floating point binary within SPSS and there is
>>always a bit of fuzz between decimal and binary numbers."
>
>True.
>
>If you display enough decimal points any decimal that does not
>convert exactly to binary will contains some bit of rounding
>error.  This was true with the earliest computers and it will remain
>true until we develop computers that do native decimal arithmetic.

Actually, the earliest computers used decimal arithmetic. It would be
quite easy to do still. Some computing devices (notably pocket
calculators) do use decimal arithmetic. But most computers use
binary, because calculations are simpler: you can get more speed and
more precision for the same amount of electronics.

Further, decimal arithmetic isn't 'native' any more than binary
arithmetic is; it's just the system we're used to. It's wisest not to
rely on any non-integer being represented exactly, in any computer
system. There are software techniques to help users live with this;
but none of them are perfect, and I can't be too upset when SPSS (or
anybody else) tweaks the way it presents nearly-equal quantities.

I've been working on a FAQ about SPSS numbers. Here's the latest version:

Draft FAQ: Precision and range of SPSS numbers

In the number representation SPSS uses,

. All integers of up to 15 decimal digits, and most 16-digit
integers, can be represented exactly.

. Non-integers, and integers larger than this, are represented to
very high precision, very nearly the same as 16 decimal digits. But,
just as 1/3 cannot be represented exactly in a fixed number of
decimal digits, many fractions cannot be represented exactly in the
binary form that SPSS uses. The fractions that cannot be represented
are *not always the same* as those that cannot be represented with 16
decimal digits.

. Values can be between about 10**-308 and 10**308

THEREFORE,

. Numbers used as identifiers, for which exact matching is essential,
should be integers of no more than 15 decimal digits.

. The precision of numbers is very nearly equivalent to 16 decimal
digits, i.e. far more than necessary for any data you're likely to encounter

. However, do not rely on exact representation of any non-integer, or
any integer with more than 15 digits.

DETAILS
-------
SPSS numbers use the 64-bit floating-point representation defined by
IEEE standard 754. It's a broadly suitable representation, and most
modern computers have hardware to do arithmetic with IEEE 754
numbers, so many applications use it.

Their precision is 53 bits, which is very close to 16 decimal digits.

All integers from 0 through 2**53 (9,007,199,254,740,992) can be
represented exactly (i.e., all through 15 digits, and most through 16 digits)

Numbers as between 2**-1024 to 2**1024 (about 10**-308 and 10**308)
can be represented, but only to 53 bits precision.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: AW: SPSS 17: wrong result computing 3 * 0.7

Art Kendall
In reply to this post by Roberts, Michael
One of the languages on the DEC-10 around the mid 70s   APL?  Algol?
MACRO? had compares the considered the fuzz.

It was very common in other languages to multiply by a constant so that
more of the digits were to the left of the decimal point and then
rounding or truncating before doing the compare.

Art Kendall
Social Research Consultants

Roberts, Michael wrote:

> As Jon Peck pointed out, using rounding with fuzzbit specified resolves this issue.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hannes Schreier
> Sent: Thursday, November 13, 2008 4:46 PM
> To: [hidden email]
> Subject: AW: SPSS 17: wrong result computing 3 * 0.7
>
> Hi,
>
> These are the results when I run Arts sytax:
>
> compute mynumber = 3*.7.
> formats mynumber (f20.16) .
> list variables = mynumber.
>
>             mynumber
>
>   2,0999999999999990
>
> formats mynumber (f5.1).
> list variables = mynumber.
>
>
> mynumber
>
>     2,1
>
> Changing the format rounds the result, but the wrong raw-value will be used in further computations . So if a simple compute command deliviers a wrong result, how much can we trust more complex analysis?
>
>
> Hannes Schreier
>
> _____________________________________
>
> Institut Schreier
> Umfragen und Analysen
>
> Postanschrift:
> Postfach 25 71
> 72015 Tübingen
>
> Hausanschrift:
> Schweickhardtstr. 1
> 72072 Tübingen
>
> Fon: 07071/538016
> Fax: 07071/538015
> www.institut-schreier.de
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Art Kendall [mailto:[hidden email]]
> Gesendet: Donnerstag, 13. November 2008 19:31
> An: Hannes Schreier
> Cc: [hidden email]
> Betreff: Re: SPSS 17: wrong result computing 3 * 0.7
>
> Are you sure that you have the same display format set?
>
> Please try something like this on each setup.
> compute mynumber = 3*.7.
> formats mynumber (f20.16) .
> list variables = mynumber.
> formats mynumber (f5.1).
> list variables = mynumber.
> Please let us know what you find.
>
> Art Kendall
> Social Research Consultants
>
> Hannes Schreier wrote:
>
>> Hi all,
>>
>> when I compute 3 * 0.7 with SPSS 15, I get the correct result 2.1.
>> SPSS 17 delivers 2.0999999999999996. Not much difference, but from
>> such an expensive software package you should expect no difference at
>> all! Hope this is fixed with the upcoming update...
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>> [hidden email] (not to SPSSX-L), with no body text except
>> the command. To leave the list, send the command SIGNOFF SPSSX-L For a
>> list of commands to manage subscriptions, send the command INFO
>> REFCARD
>>
>>
>>
>>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17: wrong result computing 3 * 0.7

Richard Ristow
At 07:39 AM 11/14/2008, Art Kendall wrote:

>One of the languages on the DEC-10 around the mid 70s   APL?  Algol?
>MACRO? had compares the considered the fuzz.

The APL implementation for the IBM 360 used a 'fuzz'; that is,
numbers were taken as equal in comparisons if they were equal within
a small fraction (the 'fuzz'). I imagine other implementations did as
well, since it was taken as an inherent feature of the language.

>It was very common in other languages to multiply by a constant so
>that more of the digits were to the left of the decimal point and
>then rounding or truncating before doing the compare.

It was, and is, wisest in all programming languages, to ensure that
values that must be retained exactly be integers, only. For example,
accounting programs in languages using floating-point arithmetic keep
(United States) currency values in cents, rather than in dollars and
cents ($12.45).

Fuzzy comparison eliminates most cases where two quantities that you
expect to be equal aren't considered so by the program, but it should
never be relied on when exact comparison is critical. (Nor is it
reliable when the precision of the numbers approaches the maximum
precision of the representation; however, that is rare with 64-bit
floating-point precision.)

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
12