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]

st: RE: I visualize a different number


From   "Radwin, David" <[email protected]>
To   <[email protected]>
Subject   st: RE: I visualize a different number
Date   Tue, 18 Jun 2013 18:02:24 -0400

Actually, a more helpful explanation is available at http://blog.stata.com/2012/04/, particularly sections 3 and 4. 

To answer your specify question of why, Stata presumably stored your variable as a float type, which is the default storage type. Integers are only stored precisely as floats in the range [16,777,216, -16,777,216], but doubles are stored precisely in the range [-9,007,199,254,740,992, 9,007,199,254,740,992]. 

Since 17,440,397,133 is outside the range of accuracy for floats but not for doubles, you should generate it as a double.

David
--
David Radwin
Senior Research Associate
Education Studies Division
RTI International
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-665-8274

www.rti.org


> -----Original Message-----
> From: Radwin, David
> Sent: Tuesday, June 18, 2013 2:53 PM
> To: '[email protected]'
> Subject: RE: I visualize a different number
> 
> 
> Try generating it as a double.
> 
> clear all
> set obs 1
> gen double x = 17440397133 in 1
> format %15.0fc x
> browse
> 
> For more information, -help data_types-.
> 
> David
> --
> David Radwin
> Senior Research Associate
> Education Studies Division
> RTI International
> 2150 Shattuck Ave., Suite 800
> Berkeley, CA 94704
> Phone: 510-665-8274
> 
> www.rti.org
> 
> 
> > -----Original Message-----
> > From: [email protected] [mailto:owner-
> > [email protected]] On Behalf Of Saidé Salazar
> > Sent: Tuesday, June 18, 2013 2:45 PM
> > To: [email protected]
> > Subject: st: I visualize a different number
> >
> > Hello guys,
> >
> > I am capturing a number in Stata, but when I use the command "browse"
> > I see a different number. Any idea of what is happening? (I see
> > 17440397312 instead of 17440397133)
> >
> > clear all
> > set obs 1
> > gen x = 17440397133 in 1
> > format %15.0fc
> > br


*
*   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