Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: rounding the minimum of a negative number


From   annoporci <[email protected]>
To   [email protected]
Subject   Re: st: rounding the minimum of a negative number
Date   Thu, 10 Jan 2013 22:19:36 +0800

Thanks Nick for these precisions.

If you want _display_ to a fixed number of decimal places, that is
ultimately a question of formatting and not a problem of numerics.

Yes. I guess another way of expressing my puzzlement is that Stata does
not display, by default, to a greater number of decimal places.

I don't know anything about this, but in Python, for instance, according
to the documentation: "On a typical machine running Python, there are 53
bits of precision available for a Python float." And, to quote more:

If Python were to print the true decimal value of the binary approximation
stored for 0.1, it would have to display:

0.1000000000000000055511151231257827021181583404541015625

So that's still quite a few zeros after the first 1. And if Stata had
displayed something like

-1.980000009999

for 1.9810, I would not have been puzzled.

I do have one last question and then I'll consider the matter closed:

Would I get a more accurate approximation of "-1.981" with Stata if I
input "-1.981000000001" than if I input "-1.981" ? in the sense that it
would "force" Stata to store the zeros after 981? (or am I
misunderstanding the whole issue?)

Thanks Nick,

--
Patrick Toche.

References:
http://docs.python.org/2/tutorial/floatingpoint.html




On Thu, 10 Jan 2013 20:15:45 +0800, Nick Cox <[email protected]> wrote:

I don't think that is a clear specification of what Stata is doing (it
doesn't "make up its own digits") or of what it should, in your view,
do instead.

If you want _display_ to a fixed number of decimal places, that is
ultimately a question of formatting and not a problem of numerics.
That is,

display %3.2 f  1 + 98/100

will ensure that you see "1.98" and this last step is in essence
string manipulation with numeric characters. But all that is done by
(e.g.)

scalar foo = 1.98

is putting a binary approximation of 1.98 in a scalar. Adding bits
will change the accuracy of the approximation (only).

Nick
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index