Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problem with reading version 4.2 DumpSave files,...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75564] Re: Problem with reading version 4.2 DumpSave files,...
  • From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 5 May 2007 06:03:02 -0400 (EDT)
  • References: <463AFEEA.6080005@gmail.com>

On 5/4/07, Terry Chung <terryisnow at yahoo.com> wrote:
> Hi Jean-Marc,
>
> Thanks for the reply! I'm going to take a closer look
> at what you suggest this weekend, although right now
> I'm not sure it will work for my case. The reason is
> because of lost digits in conversion to base 10 (for
> displaying on the screen in the Mathematica GUI).
> What your doing seems very similar to the Save[]
> function I used to use to save my numbers in between
> runs of my simulation. What I discovered was that
> Save[] converts the number to base 10 (from the
> internal binary representation within Mathematica and
> all computers) to write to the external file. When I
> read the number back in, it was sometimes slightly
> different when I compared it to the unsaved version
> of the same number.
>
> What I really need is a method for saving the exact
> binary representation of that number in an purely
> text format and a reciprocal method for reading that
> number back in.
>
> Does that make sense?
>
> Terry

Hi Terry,

In addition, you could use BaseForm to convert the numbers in binary
form. A quick and dirty example follows (just to give you an overall
idea).

In[1]:=
expr={{1.234567987654*^6,-34.3892839,898890.7348327,-8.748328494823489*^8},{\
124567.98764,-8934.3892839,89890.7348327,-8.78907284948235*^9}}

Out[1]=
            6                                8
                  9
{{1.23457 10 , -34.3893, 898891., -8.74833 10 }, {124568., -8934.39,
89890.7, -8.78907 10 }}

In[2]:=
data = (StringReplace[#1, Characters["{ 2}"] -> ""] & ) /@
   (ToString[BaseForm[NumberForm[#1, {20, 20}, NumberPadding -> {"0",
"0"}, SignPadding -> True,
        ExponentFunction -> (Null & )], 2]] & ) /@ expr

Out[2]=
{0100101101011010000111.1111110011010110111001000111111,-100010.\
01100011101010000001110000010011010110111111111,011011011011101001010.\
101111000001110111111110111011101,-110100001001001110001111010001.\
011110110111101100111
,011110011010010111.1111110011010101111110011001110001,-10001011100110.\
01100011101010000001110000010011010111,010101111100100010.\
101111000001110111111110111011101001,-1000001011110111101001101111010001.\
01111011011110110100
}

HTH,
Jean-Marc

>
> --- Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
> wrote:
>
> > terry wrote:
> > > Dear Mathematica Guru's,
> > >
> > > Because of a Mathematica bug (which still isn't
> > fixed in the just
> > > released version 6), my version 4.2 DumpSave files
> > cannot be read by
> > > my version 5.2. So as a result I'm trying to find
> > a way to _exactly_
> > > write out these numbers to a pure ascii text file
> > from within 4.2,
> > > then read them in as text and convert them back
> > into number form
> > > within 5.2 without losing any digits. Any idea's
> > how I could
> > > accomplish this simply?
> > >
> > > Note that simply saving the approximate real
> > numbers with Save[] and
> > > retreiving them will not work in this case because
> > Save[] 'distorts'
> > > the numbers even if they are loaded back into the
> > same version of
> > > Mathematica (when it converts to base 10 and
> > back).
> > >
> > > Thanks in advance!
> > >
> > > Regards,
> > > Terry
> > >
> > >
> >
> > ToString and NumberForm should be what you need
> > before Export. Knowing
> > nothing about the kind of numbers you are dealing
> > with and the data
> > structure, it is hard to tell more. You can check
> > the following thread
> > to see some examples of the above mentioned
> > functions in action.
> >
> >
> http://forums.wolfram.com/mathgroup/archive/2007/Apr/msg00523.html
> >
> > Regards,
> > Jean-Marc
> >
>
>
>
>
> ____________________________________________________________________________________
> Get your own web address.
> Have a HUGE year through Yahoo! Small Business.
> http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
>


  • Prev by Date: Re: Creating boxes in text cells.
  • Next by Date: Re: [Mathematica 6] What happened to the 5.2 HELP interface?
  • Previous by thread: Re: Problem with reading version 4.2 DumpSave files,...
  • Next by thread: Re: Problem with reading version 4.2 DumpSave files,...