Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Thanks (was Precision issues with double storage type)


From   Hiroshi Maeda <[email protected]>
To   [email protected]
Subject   st: Thanks (was Precision issues with double storage type)
Date   Wed, 08 Aug 2007 10:52:30 -0600

Dear Maarten, Keith, and Austin,

Thank you for your advices. I now understand storage and precision issues much better. I almost never deal with fractions and my grasp of precision issues turns out to be not as good as I thought.

Hiroshi Maeda

P.S. Recently there was a thread about perceived cultural differences beneath the "harshness" of some postings. Here is another occasion of "cultural differences": I would have liked to address Maarten, Keith, and Austin with their respective titles and last names (e.g., Prof. Buis, as opposed to Maarten). But I could not tell Keith and Austin's titles. Hence I resorted to the good old American way of indiscriminately calling anyone by their first name regardless of their stature :-) This may sound almost medieval, but some of us want to be polite to those who offer help. Please note that I have no intention of starting a new thread concerning cultural differences by my comment. If you feel compelled to comment on my medieval way, please do so privately.



Date: Tue, 7 Aug 2007 08:57:25 -0400
From: "Austin Nichols" <[email protected]>
Subject: Re: st: Precision issues with double storage type (??)

Hiroshi Maeda <[email protected]>:
Maarten has already indicated how to avoid the precision problems you
are encountering, and where to read more about them.  Keith has
indicated that double precision does not guarantee that sums and
differences will work out exactly (if fractions cannot be represented
perfectly in binary numbers).  Here is another way of expressing your
example that demonstrates (among other things) that
float(x)-float(y)!= float(x-y) in general:

clear
set type double
input id dep pay ref
  1   61.42   21.30   40.12
  2   69.00   68.49    0.51
end
set type float
foreach v in dep pay ref {
 g f`v'=`v'
 }
d
g c1=1 if float(fdep)==float(fpay)+float(fref)
g c2=1 if float(fdep)==float(fpay+fref)
li, noo
di %22.16f dep[1], %22.16f pay[1], %22.16f dep[1]-pay[1]
di %22.16f ref[1], %22.16f dep[1]-pay[1]
di %22.16f 40.12, %22.16f dep[1]-pay[1]


On 8/6/07, Hiroshi Maeda <[email protected]> wrote:
I am puzzled by the discrepancies between what I expect Stata to do and
what it actually does, and I suspect storage/precision issues have
something to do with it. Before you castigate me for beating this dead
horse yet once again, please note that I have read relevant manual
entries ([U] 13.10 Precision and problems therein) and statalist
postings and that I encounter this problem even when numeric variables
with fractions are stored in -double-
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index