# Function that puts zero after a certain decimal in every element of the matrix

We know that in Mathematica there is some default precision, which you can also change. This means, that after a certain decimal(fixed by the precision), the computer puts pseudo random numbers. I am looking for a function F that would put everything zero after a certain decimal. Let us say I want this to be the fourth decimal, then

F[0.12345678]=0.12340000

Does such function exist?

Thank you

-
Floor[0.12345678, 0.0001] gives 0.1234 and if you want 4 zeros to the right you can use NumberForm[Floor[0.12345678, 0.0001],{4,8}] –  tchronis Nov 3 '13 at 11:55
@tchronis thanks great, and can you think of something equivalent for matrices? You can use it for a matrix, but I have realized that after you use it with matrix, Mathematica does not consider it a matrix any more, for example you can do Eigensystem afterwards –  Mencia Nov 3 '13 at 12:01
Thanks @Mencia , you can apply Floor to the matrix. I suppose you have rectangular Matrices. Floor[matrix,0.0001] works in my machine. And for nice output you can apply the NumberForm function. –  tchronis Nov 3 '13 at 12:05
@tchronis great man, that is exactly what I needed, appreciate!! –  Mencia Nov 3 '13 at 12:11

Here are two approaches (trying to emulate the fomratting it just the truncation):

f[x_, n_] := N[IntegerPart[10^n x]/10^n, StringLength@ToString@x]


or

g[x_, n_] := N[Floor[10^n x]/10^n, StringLength@ToString@x]


Evaluating:

f[0.12345678,4]

g[0.12345678,4]


yield:

0.12340000

-