| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: strange behavior using round function
Apparently 80.54 can not be held exactly in binary double precision.
Try -search precision- and follow some of the links. If you really just
want to display the result, use the formating available with display:
displ %6.2f `t2_y'
Otherwise, you may want to read some of the related faqs.
Michael Blasnik
[email protected]
----- Original Message -----
From: "Nicola Tommasi" <[email protected]>
To: <[email protected]>
Sent: Tuesday, September 12, 2006 12:08 PM
Subject: st: strange behavior using round function
hi all,
I would appreciate if someone could help me understand why the ROUND
function behaves so differently when calculating t1_y and t2_y
The result for t2_y should be 80.54
Below follows the code.
Thanks
Sincerely,
Nicola Tommasi
. matrix list mati;
mati[2,2]
c1 c2
r1 818 1535
r2 248 371
. di "`tot1'";
1066
. di "`tot2'";
1906
. local t1_y = round(mati[1,1]/`tot1'*100, 0.01);
. local t2_y = round(mati[1,2]/`tot2'*100, 0.01);
. di "`t1_y'";
76.74
. di "`t2_y'";
80.54000000000001
______________________________________________________________
dott. Nicola Tommasi
Centro Interdipartimentale di Documentazione Economica (C.I.D.E)
University of Verona
via dell'Artigliere, 19
37129 Verona (Italy)
tel.: +39-045-8028048
fax.: +39-045-8028047
_______________________________________________________________________
*
* 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/