Statalist The Stata Listserver


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

Re: st: Re: Rounding


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: Re: Rounding
Date   Sat, 2 Jun 2007 11:48:12 -0400

Danielle-

You don't say why you want to round. If you simply want a nice display, use a format:

di %6.3g e(r2)

Or
local r2_1 = e(r(2))
di "R-Square (Model 1) = " %6.3g `r2_1'


-Steven
On Jun 1, 2007, at 3:34 PM, Austin Nichols wrote:


Danielle Ferry--
This is the well-worn precision question: the number _is_ rounded, but
a computer can store a decimal representation _exactly_ only if it is
a power of 2, e.g. 0.125 (see
http://www.stata.com/support/faqs/data/mod.html and
http://www.stata.com/support/faqs/data/prec.html for more detail).

local r2_1 = round(0.94653, 0.001)
di %32.31g `r2_1'
             .94700000000000006

On 6/1/07, Rodrigo A. Alfaro <[email protected]> wrote:
I don't think so
R
local r2_1 = round(0.9465342199934567892345, 0.001)
di `r2_1'
.947

----- Original Message -----
From: "Ferry, Danielle (Exchange)" <[email protected]>
To: <[email protected]>
Sent: Friday, June 01, 2007 2:31 PM
Subject: st: Rounding
> Stata fails to round some numbers. Why? And can I do something about
> this?
> Here is the command I am using:
> local r2_1 = round(e(r2), 0.001)
> Here is a number that is not being rounded:
> .9470000000000001
*
*   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