I am working on a financial/banking type application and part of the work is to import numeric data of 15 to 20 digits of precision. I am having trouble determining the best way this should be done. Here is an example highlighting my problem.
Imported data is a CSV file, the example below shows three comma-separated numbers:
1.00000000000001, 2.1234567890123456789,3.01
Using the statement:
x = Import["precisionTest.csv"];
x
{{1.,2.1234567890123456789,3.01}}
Testing the precision of each list item:
Precision[x[[1]][[1]]]
MachinePrecision
Precision[x[[1]][[2]]]
19.327
Precision[x[[1]][[3]]]
MachinePrecision
So, in my list, my precise number 1.00000000000001 is truncated to 1.0, where as the second number's high precision is honored by the input, and the third number is correctly interpreted fitting within MachinePrecision. This stumped me. Why did the first number, 1.00000000000001, get truncated whereas the second one did not. I would expect the same behavior for both.
I redid my import but first I set the \$MinPrecision constant to 20 yet I got exactly the same results. Maybe this failed for reasons of using $MinPrecision incorrectly.
[More] I noticed that using the AccountingForm function on my list x reclaimed the correct value, that is:
AccountingForm[x,20]
{{1.00000000000001,2.1234567890123456789,3.01}}
So, I get that for display only I guess -- But, why is the first number truncated (as I asked earlier) whereas the second one is left with full precision to represent the imported number?
RealDigits[x[[1]][[1]]]
you'll see your 10^-14 digit is there. $\endgroup$AccountingForm
as well asNumberForm
round the display of the second entry so it ends in679
.. The most reliable way to see what you really have seems to beInputForm
orFullForm
$\endgroup$