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: error calculating powers


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: error calculating powers
Date   Tue, 11 Feb 2014 12:12:02 +0000

See the help on -precision-. You need a -double-.

. set obs 1
obs was 0, now 1

. gen double x1 = 3333^3

. gen x2 = 3333^3

. format %21x x*

. l

     +-----------------------------------------------+
     |                    x1                      x2 |
     |-----------------------------------------------|
  1. | +1.13dd59efa0000X+023   +1.13dd5a0000000X+023 |
     +-----------------------------------------------+

. format %15.0f x*

. l

     +---------------------------+
     |          x1            x2 |
     |---------------------------|
  1. | 37025927037   37025927168 |
     +---------------------------+

Nick
njcoxstata@gmail.com


On 11 February 2014 10:59, Y.R.E. Retamal <yrer2@cam.ac.uk> wrote:
> Dear list
>
> I need to calculate large numbers using STATA. For example, 3333^3 =
> 37025927037
>
> However, when I calculate it using STATA,
>
> g example=3333^3
> format %15.0f
>
> The "example" variable shows the following values: 37025927168, quite
> different from the true value.
> Do you have any idea about this?
>
> Rodrigo
> *
> *   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/


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