Re: Outputting to file with fixed decimal digits

*To*: mathgroup at smc.vnet.net*Subject*: [mg75285] Re: Outputting to file with fixed decimal digits*From*: do.not at reply.nonet*Date*: Tue, 24 Apr 2007 03:19:33 -0400 (EDT)*Organization*: University Of Oxford, England*References*: <f0ekbt$pnn$1@smc.vnet.net>

Larry I reckon you need to write a function that does the basic formatting process for you into a string, here a simple example that rounds the number "x" to the nearest "d" decimal places: decfom[x_,d_]:=ToString[Floor[x*10^d+0.5]/10.^d] Then write the result to a text file, with commas etc as you fancy look at the help for the "Export" and "WriteString" functions as a start. I have used that sort of thing to write mesh definitions for Finite Element input files, where repeatability is more important than precision. I have suggested using the "Floor" function - it's to avoid the "Round" function which has the most bizarre definition in Mathematica - it doesn't give the same answer every time. (Look in "Further Examples" in the Help on "Round") It's one reason that makes me think Mathematica is not really "Engineering Grade" software and suspicious that there may be more weird things that I just haven't come across yet. Robert actuary at mchsi.com wrote: > Hello: > > I'm trying to create a file that becomes input to another software > package. I need to output real numbers with a fixed number of decimal > digits with spaces separating the numbers that I write to the file. > > I've searched this group for assistance on my question and couldn't > find anything dealing with outputting to a file. > > Help would be greatly appreciated. > > Larry

**Follow-Ups**:**Re: Re: Outputting to file with fixed decimal digits***From:*Daniel Lichtblau <danl@wolfram.com>

**Re: Re: Outputting to file with fixed decimal digits***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>