2
$\begingroup$

Consider a table

tabb={{1.233546576,2.454546565},{22334.46687875465,6787233.3565665655}}

I want to convert it into a table where all the numbers are only with 4 digits after the comma, and then export it (to save size of the output file).

This is what I do:

tabbSh={NumberForm[#[[1]], 4],NumberForm[#[[2]], 4]}&/@tabb

However, the elements of the resulting table become non-numeric. Could you please tell me how to fix this problem?

$\endgroup$
4
  • 5
    $\begingroup$ When you say 4 digits, do you want a rounding or truncation? e.g., Round[tabb, 0.0001] $\endgroup$
    – Syed
    Feb 20, 2023 at 10:40
  • 2
    $\begingroup$ If you just want to truncate digits, you can try something like: foo[x_, n_] := N[FromDigits[RealDigits[x, 10, n]], n] $\endgroup$
    – bmf
    Feb 20, 2023 at 10:55
  • 3
    $\begingroup$ Similar questions: 143294 (unanswered) 970, 241413, 19387. In which format do you want to Export? $\endgroup$
    – rhermans
    Feb 20, 2023 at 10:58
  • $\begingroup$ Thank you guys! $\endgroup$ Feb 20, 2023 at 12:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.