I have a numeric variable in a dataset (x1) containing integers and numbers with one decimal place.
I'm creating a new variable (x2) that assumes the same value as x1 by running:
gen x2 = x1
When I run this command, some of the stored values in x2 are not exactly the same to some of the values for x1. For example, a value that was originally "7.6" in the original variable x1 is now "7.5999999" in the new variable x2. Another value that was originally "0.6" in x1 is now "0.60000002" in x2.
Why is this discrepancy happening? Is there something I can do to ensure the values in the two variables are exactly the same?
I'm creating a new variable (x2) that assumes the same value as x1 by running:
gen x2 = x1
When I run this command, some of the stored values in x2 are not exactly the same to some of the values for x1. For example, a value that was originally "7.6" in the original variable x1 is now "7.5999999" in the new variable x2. Another value that was originally "0.6" in x1 is now "0.60000002" in x2.
Why is this discrepancy happening? Is there something I can do to ensure the values in the two variables are exactly the same?
Comment