0

I would like to save data to a txt file. I use for this

PutAppend[ " x= ", N[x], " y= ", N[y], "D:/Users/.../file.txt"]]

But the number of decimal places that Mathematica writes to the file does not suit me, I would like to have more decimal places, for example 30. So I rewrote this code as follows:

PutAppend[ " x= ", N[x,30], " y= ", N[y,30], "D:/Users/.../file.txt"]]

But the number of decimal places recorded in this file remains unchanged and ranges from 14 to 17. Could you explain to me how I can save the number of decimal places I need in a file?

Mam Mam
  • 1,843
  • 2
  • 9

1 Answers1

3

The reason is that x is a machine number with 15 or 16 valid digits. Therefore, you can not get more than 16 digits out of it.

E.g.: consider:

x=1/3. //Full Form

enter image description here

This is a machine number. If you try to get 30 digits, you do not get more digits:

N[x,30] //FullForm

However, if you have a number with more digits, like:

x=1/3

This ha an infinite number of valid digits.Therefore if you say:

N[x, 30]

enter image description here

you get 30 digits in this case.

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57