I want to truncate a simple number to n decimal digits. For example, 2/3. I used
f[x_, n_] := N[IntegerPart[x 10^n]/10^n]
but I get
f[2/3, 20] = 0.666667
Is there a way to get
f[2/3, 20] = 0.66666666666666666666
?
I have searched a lot but I haven't really found an answer. I am looking for something like N
or Round
for truncation.
N[2/3, 20]
$\endgroup$N
rounds the last decimal digit. I getN[2/3, 20] = 0.66666666666666666667
$\endgroup$RealDigits[2/3, 10, 20]
$\endgroup$NumberForm[N[2/3], 30]
stops after 15 to 16 decimals but does not round up. $\endgroup$