Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: AW: float function question


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: AW: float function question
Date   Wed, 17 Jun 2009 12:11:30 +0100

-search precision- gives a full array of references, some but not all of
which have been mentioned previously. Note in particular 

FAQ     . . . . . . . . . . . . . . . . . . . Results of the mod(x,y)
function
        . . . . . . . . . . . . . . . . . . . . . N. J. Cox and T. J.
Steichen
        2/03    Why does the mod(x,y) function sometimes give
                puzzling results?
                Why is mod(0.3,0.1) not equal to 0?
                http://www.stata.com/support/faqs/data/mod.html

FAQ     . . . . . . . . . . . . . . . . .  The accuracy of the float
data type
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W.
Gould
        5/01    How many significant digits are there in a float?
                http://www.stata.com/support/faqs/data/prec.html

FAQ     . . . . . . . . . Comparing floating-point values (the float
function)
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  J.
Wernow
        3/01    Why can't I compare two values that I know are equal?
                http://www.stata.com/support/faqs/data/float.html

FAQ     . . . . . . . . .  Why am I losing precision with large whole
numbers?
        . . . . . . . . . . . . . . . . . .  UCLA Academic Technology
Services
        7/08    http://www.ats.ucla.edu/stat/stata/faq/longid.htm

SJ-8-2  pr0038  Mata Matters: Overflow, underflow & IEEE floating-point
format
        . . . . . . . . . . . . . . . . . . . . . . . . . . . .  J. M.
Linhart
        Q2/08   SJ 8(2):255--268                                 (no
commands)
        focuses on underflow and overflow and details of how
        floating-point numbers are stored in the IEEE 754
        floating-point standard

SJ-6-4  pr0025  . . . . . . . . . . . . . . . . . . .  Mata matters:
Precision
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W.
Gould
        Q4/06   SJ 6(4):550--560                                 (no
commands)
        looks at programming implications of the floating-point,
        base-2 encoding that modern computers use

SJ-6-2  dm0022  . Tip 33: Sweet sixteen: Hexadec. formats & precision
problems
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q2/06   SJ 6(2):282--283                                 (no
commands)
        tip for using hexadecimal formats to understand precision
        problems in Stata

Nick 
[email protected] 

Martin Weiss

Also note the FAQ on this point:
http://www.stata.com/support/faqs/data/float.html
http://www.stata.com/support/faqs/data/prec.html

David Airey

Why does the float function not work like this? I feel silly.

clear
input float x
0.00
0.01
0.03
0.10
0.30
1.00
end
generate str4 x_str = ""
replace x_str = "0.00" if float(x) == 0.0
replace x_str = "0.01" if float(x) == 0.01
replace x_str = "0.03" if float(x) == 0.03
replace x_str = "0.10" if float(x) == 0.1
replace x_str = "0.30" if float(x) == 0.3
replace x_str = "1.00" if float(x) == 1.0
list, clean

which gave

. list, clean

          x   x_str
   1.     0    0.00
   2.   .01
   3.   .03
   4.    .1
   5.    .3
   6.     1    1.00

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index