[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: Re: a question on function int
It is really helpful! Thanks, Michael!
> It has nothing to do with the int() function, it has to do with
> temzzz does not contain .005, but instead 0.0049999998882.... Try -
> precision- and check out the various FAQs at the end to learn more.
> can sometimes address these problems by using doubles instead of
> other cases you can use the float() function and sometimes just using
> round() works. In your case, I would keep long integer IDs as string
> variables to avoid precision issues and allow easier access to
> Michael Blasnik
> ----- Original Message -----
> From: "Jian Zhang" <firstname.lastname@example.org>
> To: <email@example.com>
> Sent: Wednesday, October 19, 2005 4:30 PM
> Subject: st: a question on function int
> > Hello,
> > I have a question about the function int that I could not understand
> > stata is doing. Hope that you can answer me. Thanks.
> > Here it is:
> > For example, I have a data set:
> > id
> > 10103005
> > after I run the following commands:
> > gen double temxxx=(id/1000)
> > gen temyyy=int(temxxx)
> > gen temzzz=temxxx-temyyy
> > gen areaxxx=int(temzzz*1000)
> > list id temxxx temyyy temzzz areaxxx
> > What I got is
> > id temxxx temyyy temzzz areaxxx
> > 10103005 10103.005 10103 .005 4
> > Is variable areaxxx supposed to be 5? Why did stata give me 4 instead
> > 5? Any clue for this?
> > Thanks.
> > Jian
> * 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: