All the elements in my list have decimals however some have digits to the right of the decimal. I would like to create a set with the elements without digits to the right of the decimal. How?
Convert numbers with no FractionalPart to an empty Sequences, which effectively eliminates them.
testList = {1.2, 2.0, 2.0001, 4537.0};
testList /. x_ /; NumberQ[x] && FractionalPart[x] == 0 -> Sequence[]
{1.2, 2.0001}
Look up Sequence in Help.
many ways to do this. Another possibility, using David’s input for test
testList = {1.2, 2.0, 2.0001, 4537.0};
Pick[testList, FractionalPart[#] > 0 & /@ testList]
(*{1.2, 2.0001}*)
But this method, and also David’s will not catch cases like 4537.000000000000000001 since FractionalPart[4537.000000000000000001] is effectively zero. So if you want to also check for such cases, a more robust test is needed. One way is to increase the Precision (there might be better ways)
testList = {1.2, 2.0, 2.0001, 4537.000000000000000001};
Pick[testList, FractionalPart[SetPrecision[#, 100]] > 0 & /@ testList]
(*{1.2, 2.0001, 4537.000000000000000001}*)