How do you force a decimal output? [duplicate]

I have some very small values such as 2.601519253*10^-8. I'd like to output these values to CSV for another program to work with. I've tried N[value, 50], but Mathematica still insists on producing scientific notation (which my program can't read).

How can I force Mathematica to output values in decimal form?

EDIT:

AccountingForm seems to be the answer to my question. AccountingForm[2.601519253458693*10^-8, 30] gives a nice decimal format I can use. –

• Maybe NumberForm is what you're looking for. – Silvia Dec 12 '12 at 6:08
• NumberForm[2.601519253458693*10^8, 30] Still results in scientific notation. Annoyingly. AccountingForm seems to be the answer to my question. AccountingForm[2.601519253458693*10^-8, 30] gives a nice decimal format I can use. – user4860 Dec 12 '12 at 6:15
• What about Export? – Sjoerd C. de Vries Dec 12 '12 at 6:31
• Duplicate of: mathematica.stackexchange.com/q/771/5 – rm -rf Dec 12 '12 at 22:53

How to format

Using AccountingForm :

I show first the output of one function for your number

n = 2.60152*10^-8  (*your number *)

(*  +0.00000002601519  *)


the first parameter is the number to format, then there is a list of 2 numbers. The first is the total number of digits you want in the field. The second number is how many digits to the right of the decimal point. This function adds zeros to the left of the decimal point if there are no other digits to fill in. This is I need to make sure the field width is always the same for each number. You can change these options as you need. Here is the function

padIt[v_?(Element[#, Reals] &), f_List] :=  AccountingForm[Chop[v] , f,
NumberSigns -> {"-", "+"},


You can change the above options shown to customize it as needed. (remove the +,- sign, change padding, etc..)

update

How to export

SjoerdC.deVries asked a good question in the comment above on how to export these numbers to a text file. This below shows one way to do it

Clear["Global*"]
SetDirectory[NotebookDirectory[]];
AccountingForm[Chop[v] , f,
NumberSigns -> {"-", "+"},

output = OpenWrite["info.txt", FormatType -> OutputForm, PageWidth -> Infinity];
\$Output = output;

n = 2.60152*10^-8 ;


Now looking at the text file foo.txt shows that the number is written in text format.

You could use this

NumberForm[2.601519253*10^-8, {16, 16},
ExponentFunction -> (If[-10 < # < 10, Null, #] &)]

(*
0.0000000260151925
*)


Export into CSV format could be done as follows: Define a function

numFormat[y_] :=
ToString@NumberForm[y, {16, 16},
ExponentFunction -> (If[-10 < # < 10, Null, #] &)]


create a few values for demonstration purposes

numberStr = Map[numFormat, (RandomReal[1, 5])*10^-8]


export to file

    Export["test.csv", numberStr]

(* contents in file test.csv
0.0000000061627008
0.0000000052266995
0.0000000039287885
0.0000000098132366
0.0000000032460654
*)
`