LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 13 Nov 2008 08:27:33 -0600
Reply-To:     "Peck, Jon" <peck@spss.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         "Peck, Jon" <peck@spss.com>
Subject:      Re: SPSS 17: wrong result computing 3 * 0.7
In-Reply-To:  A<D256A586913C45409DA1F38CFDEEF1B6020F8778@ahcamail.fdhc.state.fl.us>
Content-Type: text/plain; charset="us-ascii"

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:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Roberts, Michael Sent: Thursday, November 13, 2008 7:17 AM To: SPSSX-L@LISTSERV.UGA.EDU 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:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Hannes Schreier Sent: Thursday, November 13, 2008 8:56 AM To: SPSSX-L@LISTSERV.UGA.EDU 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 LISTSERV@LISTSERV.UGA.EDU (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 LISTSERV@LISTSERV.UGA.EDU (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 LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page