|
This is why computers are so dangerous when casually used. It should
NOT be news to anyone that computers do arithmetic in *binary* and numbers defined by ratios of integers may not have a finite representation. Whatever you *see*, the internal value of any non-integer has a certain fuzziness which cannot be "fixed" as Jonathon Fry suggests. Extending Art Burke's example: data list /x (f3.1). begin data 2.1 2.1 end data. compute y=3*0.7. compute z=x-y. compute comp= (x=y). execute. You see that comp evaluates as zero (false). It's *sooo* easy to use floating point comparisons to select cases then wonder why it went wrong. Allan *********************************************************************************** This email and any attachments are intended for the named recipient only. Its unauthorised use, distribution, disclosure, storage or copying is not permitted. If you have received it in error, please destroy all copies and notify the sender. In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent. All emails may be subject to monitoring. *********************************************************************************** ===================== 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 |
|
Following Art's suggestion
http://docs.sun.com/source/806-3568/ncg_goldberg.html the maths is too much for me - but I assume not for others :-) Dr Muir Houston Lecturer DACE Faculty of Education University of Glasgow 0141-330-4699 ________________________________ From: SPSSX(r) Discussion on behalf of Allan Reese (Cefas) Sent: Fri 14/11/2008 10:00 To: [hidden email] Subject: Finite arirthmetic: was SPSS 17: wrong result computing 3 * 0.7 in SPSSX-L Digest - 12 Nov 2008 to 13 Nov 2008 (#2008-314) This is why computers are so dangerous when casually used. It should NOT be news to anyone that computers do arithmetic in *binary* and numbers defined by ratios of integers may not have a finite representation. Whatever you *see*, the internal value of any non-integer has a certain fuzziness which cannot be "fixed" as Jonathon Fry suggests. Extending Art Burke's example: data list /x (f3.1). begin data 2.1 2.1 end data. compute y=3*0.7. compute z=x-y. compute comp= (x=y). execute. You see that comp evaluates as zero (false). It's *sooo* easy to use floating point comparisons to select cases then wonder why it went wrong. Allan *********************************************************************************** This email and any attachments are intended for the named recipient only. Its unauthorised use, distribution, disclosure, storage or copying is not permitted. If you have received it in error, please destroy all copies and notify the sender. In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent. All emails may be subject to monitoring. *********************************************************************************** ===================== 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 |
| Free forum by Nabble | Edit this page |
