Hi,
I met a very strange problem in SPSS. During the calculation, a value was displayed as “0.000375” in SPSS data, but when rounding this number to have 5 decimal places, it gives you “0.00037” instead of “0.00038”. I used "set fuzzbits=10". When I save the SPSS data into excel, this value was displayed as “0.000374999999999695” in excel, and I think this is an internal representation, which after rounding will give you “0.000375”. But, why this happens? and how to avoid this kind of issue? As in excel, if you do the same calculation, it will give you "0.000375". should I change "set fuzzbits=xx"? Thanks, |
Administrator
|
What exactly is the problem?
I see no issue! -------------------------
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In SPSS, it displayed as 0.000375, after rounding it should be 0.00038, but it gives 0.00037 in SPSS. The reason why it gave 0.00037 is that in SPSS, it uses "0.000374999999999695" to represent "0.000375", and this is evidenced by the fact that if saving the SPSS file to excel, it displayed this value in the cell.On Wed, Oct 8, 2014 at 9:53 PM, David Marso [via SPSSX Discussion] <[hidden email]> wrote: What exactly is the problem? |
Here are a few examples of rounding up like you want, but this seems pretty silly of a request.
*******************. DATA LIST FREE / X (F14.12). BEGIN DATA 0.000374999695 END DATA. COMPUTE #XT = RND(X ,0.000001). COMPUTE X2 = RND(#XT,0.00001). COMPUTE X3 = RND(X+0.000001,0.00001). EXECUTE. FORMATS X2 X3 (F14.12). LIST ALL. *******************. |
The apparently trivial operation of rounding
is actually numerically challenging because of the nature of floating point
arithmetic. You can find some extended discussions of this in the
X list archives. In general, Statistics uses a round-to-even algorithm
for values exactly on or near the rounding boundary. This is done
in order to prevent the bias that would occur if boundary values were always
rounded up. You can experiment with different FUZZBITS settings to
see the effect, but FUZZBITS does not affect internal calculations.
Try FUZZBITS = 0, 6, and 20 to see the effect. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Andy W <[hidden email]> To: [hidden email] Date: 10/08/2014 06:30 AM Subject: Re: [SPSSX-L] SPSS rounding issues Sent by: "SPSSX(r) Discussion" <[hidden email]> Here are a few examples of rounding up like you want, but this seems pretty silly of a request. *******************. DATA LIST FREE / X (F14.12). BEGIN DATA 0.000374999695 END DATA. COMPUTE #XT = RND(X ,0.000001). COMPUTE X2 = RND(#XT,0.00001). COMPUTE X3 = RND(X+0.000001,0.00001). EXECUTE. FORMATS X2 X3 (F14.12). LIST ALL. *******************. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-rounding-issues-tp5727536p5727540.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 |
In reply to this post by albert_sun
At 07:07 AM 10/8/2014, albert_sun wrote:
>The reason why it gave 0.00037 is that in SPSS, it uses >"0.000374999999999695" to represent "0.000375", and this is >evidenced by the fact that if saving the SPSS file to excel, it >displayed this value in the cell. That is not the value that SPSS uses; SPSS uses a binary, not a decimal, representation. That is, I assume, a 15-digit decimal approximation of the SPSS value. But you're right: the exact value "0.000375" is not representable in SPSS(*). If the closest approximation is just below the exact value, as it seems to be, yes, it'll round down. If you're depending on the value to be exact, you should probably multiply it by 1E6 so it's an integer; "375" *is* exactly representable. But this raises the question: Why does the problem arise? Are you trying to 'bin' your data, by rounding to two significant digits? ===================== 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 |
Free forum by Nabble | Edit this page |