Re: How to write formatted number into a file
- To: mathgroup at smc.vnet.net
- Subject: [mg66620] Re: How to write formatted number into a file
- From: dh <dh at metrohm.ch>
- Date: Wed, 24 May 2006 03:02:08 -0400 (EDT)
- References: <e4tdu3$9o0$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Steve, you have 3 problems: 1)You want the ..E..notation 2) You want to control the number of digits printed 3) By default Put writes in a form Mathematica can read back, that is InputForm. All can be solved by "NumberForm": 1) with the option NumberFormat you can exactly tell how to print, e.g.: NumberFormat -> (SequenceForm[#1, "E", #3] &) 2) The number of digits is the second argument for "NumberForm". An extended form is {n,m}, see manual. 3) You must force Put to write in "OutputForm" by wrapping the number into "OutputForm". Therefore, alltogether will e.g. look like: Put[OutputForm[ NumberForm[ 1.23456789*10^-6, 6, NumberFormat -> (SequenceForm[#1,"E", #3] &)] ] , "FileName"] Daniel phd related wrote: > Hi, I am try to write a formated number into a file. For example, Writing > 6.661999999999944*10^-6 as 6.66200E-06 . > If I use ScientificForm and can see the format 6.66200E-06 in mathematica, > however when i am trying to write it into a file like the what i see in > mathematica, > the I see ScientificForm instead of the result i desired. > How to tackle this problem? >