3

Is there a quick and easy way to truncate a decimal number, say beyond 4 digits, in MATHEMATICA?

With N[1/6, 4] it rounds to =1.6667.

I want you to cut to 1.6666.

Thanks!

Anthony
  • 36,459
  • 25
  • 97
  • 163
jose
  • 35
  • 6

1 Answers1

4
f[x_, n_] := N[IntegerPart[x 10^n]/10^n]

f[1/6, 4]

1.6666

However, note

f[N[531/25], 4]

21.2399

so really some further refinement is required.

Chris Degnen
  • 8,443
  • 2
  • 23
  • 40