# Decimal format in Mathematica exported output

I am using ReadList to read an input file as Table format, and exporting the results. The input.m file contains expression (say exp). In the file I have the numerical values for the variables.

Block[{}, Export["output.m", ReadList["input.m"], "Table"] ]


While it is printing small numbers as decimal (e.g. 771640.5749154771), for bigger numbers it changes to a different format, like 2.8702708449431164e6.

Is it possible to keep the decimal format for those large numbers as well?

There are some solutions using DecimalForm, NumberForm etc. However I do not know how to implement those in this particular piece of code. Should I enclose the exp as NumberForm[exp, 15]? Or is there any alternate solution like globally setting \$NumberForm?

The "Table" export format uses CForm to format content. So, one possibility is to block CForm to something that formats the way you want:

Block[{CForm = OutputForm @* (DecimalForm[#,15]&)},
ExportString[
{771640.5749154771, 2.8702708449431164*^6},
"Table"
]
]

"771640.574915477
2870270.84494312"


For Mathematica versions before 11.2, you can use NumberForm with an ExponentFunction option :

Block[{CForm = OutputForm @* (NumberForm[#, 15, ExponentFunction->(Null&)]&)},
ExportString[
{771640.5749154771, 2.8702708449431164*^6},
"Table"
]
]

"771640.574915477
2870270.84494312"

• Thanks. Somehow on my mathematica (Mathematica 11.0.0 for Mac OS X x86 (64-bit)), DecimalForm does not give your output but gives DecimalForm[2.87027 10^6 , 15]. But changing to AccountingForm gives me your output. Mar 16, 2019 at 5:40
• But then problem with the AccountingForm is that it does not recognise negative numbers. Mar 16, 2019 at 5:50
• @Boogeyman See update Mar 16, 2019 at 19:12