float(x)
Domain: -1e+38 to 1e+38
Range: -1e+38 to 1e+38
Description: returns the value of x rounded to float precision.
Although you may store your numeric variables as byte, int, long,
float, or double, Stata converts all numbers to double before
performing any calculations. Consequently, difficulties can arise in
comparing numbers that have no finite binary representations.
For example, if the variable x is stored as a float and contains the
value 1.1 (a repeating "decimal" in binary), the expression x==1.1
will evaluate to false because the literal 1.1 is the double
representation of 1.1, which is different from the float
representation stored in x. (They differ by 2.384 x 10^(-8).) The
expression x==float(1.1) will evaluate to true because the float()
function converts the literal 1.1 to its float representation before
it is compared with x. (See [U] 13.11 Precision and problems therein
for more information.)