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: RE: RE: estimate precision in MATA


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: estimate precision in MATA
Date   Wed, 22 Sep 2010 08:08:31 -0500

On Wed, Sep 22, 2010 at 2:25 AM, Marie-Claire Robitaille-Blanchet
<[email protected]> wrote:
> Let say I want to sum two variables. I can use format to increase the number of digits after the decimal point for the new variable = old_variable_1 + old_variable_2.
>
> I'm looking for the equivalent but when I sum matrixes in MATA. So I want to increase the number of digit after the decimal point for the new matrix I'm creating from already existing matrixes. And, if possible, I would prefer the entry in the new matrix to be in the data type: double.

Mata already operates in double precision. If you need even higher
precision for your computations, there are -quad*()- functions
available. For each individual number, you can -printf()- it in the
format you like:

. mata
: pi()
  3.141592654

: printf("%20.18f",pi())
3.141592653589793100

Here, of course, the trailing zeroes are wrong, but Stata may have no
way of figuring out that they are.

-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

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


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