I noticed that SetPrecision doesn't actually guarantee that my number is as precise as I want:
prec=20; SetPrecision[1.0, prec] SetPrecision[1.1, prec] Out[666]= 1.0000000000000000000 Out[667]= 1.1000000000000000888 I know one way to prevent this would be to replace 1.1 with 11/10, but this gets pretty cumbersome when adding more digits after the decimal. Another way is to use 1.1`20 (thanks @J.M.) but I need to use a variable precision. Is there a better way?
1.1`20. $\endgroup$Rationalize[], but that doesn't work in general. $\endgroup$