4
$\begingroup$

I have a following problem. My code is for simplicity:

h = Table[{SetPrecision[i, 3], SetPrecision[(1+I)/(1 + i^2), 50]}, {i, 0, 
    10, 1/100}];
Export["test.txt", h, "Table"]

I want those number to have really 50 decimal places. But the output test.txt reads:

0   1.`50.+1.`50.*I
0.01    0.9999000099990000999900009999000099990000999900009999000099990000999900009999`50.+0.9999000099990000999900009999000099990000999900009999000099990000999900009999`50.*I
...

Why are there those '50? It really annoys me and I can't get rid of this. This problem occurs when complex numbers are involved (that 1+I part), but the output is correct when only reals are exported.

$\endgroup$

1 Answer 1

6
$\begingroup$

Try using:

h = Table[{SetPrecision[i, 3], SetPrecision[(1+I)/(1 + i^2), 50]}, {i, 0, 10, 1/100}];
Block[{$NumberMarks = False},
    Export["test.txt", h, "Table"]
];
$\endgroup$
1
  • $\begingroup$ Well, that takes care of that! Thank you. $\endgroup$
    – user16320
    Apr 27, 2017 at 2:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.