Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I try to import data with ReadList from a file containing very small numbers (~10^-318), positive data is handled well, whereas negative data casts an error:

"General::digit: "Digit at position 1 in !(\"-5.5137726\") is too large to be used in base 10."

The actual number in the file is -5.5137726e-318. It works fine for positive numbers, or smaller exponents. I know Import handles well the data, but wanted to use ReadList since its ~10 times faster. I also tried truncating the data in the text file (in case it was a precission problem), to no avail.

Using Mathematica 9.0.1 with Windows 7 Home Premium.


Here is a sample of the data; its a list of the components of a 3D vector:

   124000            0            0
   124000 -5.5137726e-318 4.9011312e-318
   124000 -6.0038857e-317 -8.1481306e-317
   124000 8.7730249e-316 -6.6839177e-316
   124000 7.2959464e-315 9.1491867e-315
   124000 -9.4449699e-314 7.9490222e-314
   124000 -8.6193193e-313 -9.6701831e-313
   124000 9.823401e-312 -9.2906591e-312
   124000 9.9467387e-311 9.9039764e-311
   124000 -9.9117558e-310 1.0571814e-309
   124000 -1.1151265e-308 -9.8472336e-309
   124000 9.7116423e-308 -1.1671959e-307
   124000 1.2122543e-306 9.5070421e-307
   124000 -9.2363979e-306 1.2493669e-305

I ran the processing code again, and it seems now that any numbers (positive or negative) smaller than 2e-318 ($MinMachineNumber) give the same error.

The Import command automatically truncates small numbers to 0:

{124000, 0, 0}, {124000, 0., 0.}, {124000, 0., 0.}, {124000, 0., 0.}, {124000, 0., 0.}, 
{124000, 0., 0.}, {124000, 0., 0.}, {124000, 0., 0.}, {124000, 0., 0.}, {124000, 0., 0.}, 
{124000, 0., 0.}, {124000, 9.71164*10^-308, -1.1672*10^-307}, 
{124000, 1.21225*10^-306, 9.50704*10^-307},  {124000, -9.2364*10^-306, 1.24937*10^-305}

I was looking for an output in this way, but with ReadList.

share|improve this question
up vote 1 down vote accepted

You can do the following:

data = ReadList["filename.ext", {Word, Word, Word}];

Then a little post processing:

ToExpression@StringReplace[#, {"e" -> "*^"}] & /@ data

Mathematica graphics

share|improve this answer
Thanks, that works well. It performs faster than Import (65ms vs 145ms), although ReadList without postprocessing is still much faster (7ms). Is there a way to make mathematica read it as an arbitrary precision number, or to change $MinMachineNumber? – Noel Mar 19 '14 at 13:51
@NoelPerezGonzalez Well, there's no way to change $MinMachineNumber since it's based on your hardware. You will notice more speed up if your file is much larger, I think this is your best approach. – RunnyKine Mar 19 '14 at 13:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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