Stata has a round()
function. One can select the units it rounds to. I want to round an arbitrary floating point value to two decimal places using round(ArbitraryValue, 0.01)
. Stata's display
seems to understand this. But somehow the internal representation of round(ArbitraryValue, 0.01)
still has the unrounded floating point value:
. local LevelA = 99.98765432123321
. ttest mpg==20, level(`LevelA') <BR>
level() can have at most two digits after the decimal point <BR>
r(198);
. local LevelB = round(`LevelA',0.01)
. di `LevelB' <BR>
99.99
. ttest mpg==20, level(`LevelB') <BR>
level() must be between 10 and 99.99 inclusive <BR>
r(198);
. set trace on
. ttest mpg==20, level(`LevelB') <BR>
[SNIP]<BR>
= local 0 mpg = 20, level(**99.99000000000001**) <BR>
[SNIP] <BR>
r(198);
What am I not understanding about how to correctly round?