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

Assume that the output of my calculation is a and is a number such as:

a = 100.1252135246354847;

N[a] gives me 100.125

However, when I try to save my data, a via export such as :

Export["/path/to/file/with/extension/dat", N[a]]

My eventual filename.dat has 100.12521352463548 and not 100.125. So is the precision of digits/most significant digits for display only?

I also tried NumberForm[a,6] and I get NumberForm[100.1252135246354847`18.000543455259304, 6] in my data file!

What am I doing wrong?

Edit (possible solution):

Replacing N[a] with SetPrecision[a,5] helped. I wasn't sure if I should have this in the ANSWER section because the solution may be quite trivial and may not warrant being in the answer section. Any thoughts on that (whether or not I should answer this question or let the solution remain as an appended "edit")

share|improve this question
By the way, after you enter N[a], edit the output (or press Ctrl+Shift+L) to see the full machine form. – amr Sep 24 '12 at 17:12
up vote 2 down vote accepted

Put the path between the quotation marks.

a = 100.1252135246354847;  
Export[StringJoin["", ToString[N[a, 6]], ".dat"], a]  


share|improve this answer

Replacing N[a] with SetPrecision[a,5] helped. The above answer by Fred Daniel Kline helps too but isn't really what I am looking for.

share|improve this answer

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.