When you use SetPrecision
to set the precision of say 1.1
you will get some seemingly random numbers padded before the rest will be padded by zeros. I assume this comes from the true machine precision representation of 1.1
having these hidden numbers.
When you use backticks you do get the more intuitive result of the expression only being padded with zeros. This seems more desirable to me since what I want is to input floats as close to exact as possible (i.e. I mean that I want 1.1
to be as close as possible to 11/10
etc.)
But how do I use the backtick as a function. The Fullform
is just the backtick and gives no hints for how to use it in a function. Naive tries such as #`40&
are not considered valid syntax.
I guess a function could be constructed by multiplying by some power of ten and then rounding to an exact number. Followed by dividing by the same power of ten and using N[#, prec]& on the result but this seems needlessly complicated.
(Alternatively, explain to me why trying to get the backtick result is a bad idea.)
1.2`3
. This text (i.e. code) is directly interpreted as a certain expression (an arbitrary precision number). $\endgroup$SetPrecision
is a function, an operation that gets carried out. First1.1
is interpreted as a machine precision number. Then it is being converted to a different expression, an arbitrary precision number. $\endgroup$N[FromDigits[RealDigits[#]],prec]
works. $\endgroup$1.1`30
not suffice? $\endgroup$