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: reversible -destring-, precision, longs v doubles
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: reversible -destring-, precision, longs v doubles
Date
Tue, 6 Aug 2013 17:29:19 +0100
I guess I wrote some zeroth version of that.
Conversion is reversible if real(string(<original>)) = <original> or
string(real(<original>)) = <original> where <original> is whatever you
feed in and -string()- can use whatever format is specified.
What this amounts to is a stipulation is that you must lose no
information, crucial if you change your mind about what should be done
to the data.
So, a reversible potato peeler or university education would restore
the potatoes or the students to their original state.
Nick
[email protected]
On 6 August 2013 17:03, László Sándor <[email protected]> wrote:
> I ran into an error with identifiers longer than -maxlong()- before
> (blame statistical offices fond of 10 digits or more). So now I wanted
> to be careful while destringing, but you cannot specify the type for
> the result — however, -destring- breaks if the process is not
> "reversible." What does it mean exactly? I cannot find it documented.
> (Actually, the default type for -destring- is double, so it is surely
> not the case the destring only produces longs unless forced to.)
>
> Do I need to worry about my identifiers becoming imprecise or rounded
> if -destring- did not warn me?
>
> The documentation of -tostring- does contain the following, but this
> is not exactly the same thing.
>
> Conversion of numeric data to string equivalents can be problematic.
> Stata, like most software, holds numeric data to finite precision and
> in binary form. See the discussion in [U] 13.11 Precision and problems
> therein. If no format() is specified, tostring uses the format %12.0g.
> This format is, in particular, sufficient to convert integers held as
> bytes, ints, or longs to string equivalent without loss of precision.
> However, users will often need to specify a format themselves,
> especially when the numeric data have fractional parts and for some
> reason a conversion to string is required.
>
> Thanks!
>
> *
> * 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/
*
* 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/