Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: How to import data without losing much precision
Replies: 5   Last Post: Dec 3, 2012 9:44 PM

 Messages: [ Previous | Next ]
 Jeff Posts: 113 Registered: 11/22/09
Re: How to import data without losing much precision
Posted: Dec 3, 2012 4:44 PM

"Steven_Lord" <slord@mathworks.com> wrote in message <k9h7q6\$4sk\$1@newscl01ah.mathworks.com>...
>
>
> "Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message
> news:k9gk4s\$2hh\$1@newscl01ah.mathworks.com...

> > I'm trying to import some data, which was created by C code, into Matlab
> > without losing much precision. Can someone show me an example of how to do
> > so?
> >
> > I have about 52 decimal places of precision, with N=16 numbers on a line,
> > like this:

>
> Double precision only allows you 52 bits of precision (well, plus the
> implicitly stored bit) not 52 digits.

The input data is 52 decimal digits, not bits, of precision. I know what I posted was a big mess (there's no preview on this board), but there are 52 decimal digits of precision in the sample input. It's a "long double" in C. If my Matlab has only 52 (or 53) binary digits of precision, which is 16 decimal digits, then I guess I've already imported the most precise information I can.

>
> *snip*
>

> > I've tried using dlmread, csvread and importdata, but they cut off
> > precision.

>
> You could read these in as _strings_ and convert them into symbolic objects
> using Symbolic Math Toolbox.
>
> *snip*
>

> > I've tried other things, too, but I cannot get any more precision. You can
> > see that their all losing precision after about 16 decimal places.

>
> Yes. See:
>
> http://en.wikipedia.org/wiki/Double-precision_floating-point_format
>

> > Could someone show me an example of how to import my data with the most
> > precision?

>
> Why do you believe you need 52 decimal digits of precision for your data?
> For comparison, you only need roughly 39 digits of pi to calculate the
> volume of the universe to within one atom.
>
> http://en.wikipedia.org/wiki/Pi#Motivations_for_computing_.CF.80
>
> Just because you HAVE the number out to N digits doesn't mean you NEED all
> those digits.

Actually, I don't know how much precision I should preserve. My adviser has been characteristically slow to respond to my questions and I've learned that I need to keep working while waiting for his response. If I don't need that much precision, then hopefully I will have at least learned something valuable along the way.

Maybe my real question should have been "How do I determine how much precision my version of Matlab has?"

>
> --
> Steve Lord
> slord@mathworks.com
> http://www.mathworks.com

Date Subject Author
12/2/12 Jeff
12/2/12 Steven Lord
12/3/12 Jeff
12/3/12 Steven Lord
12/3/12 Nasser Abbasi
12/3/12 Roger Stafford