Re: Type of array to store large numbers [message #80266 is a reply to message #80265] |
Fri, 25 May 2012 06:36   |
Russell Ryan
Messages: 122 Registered: May 2012
|
Senior Member |
|
|
On May 25, 9:07 am, Sir Loin Steak <lj...@fsmail.net> wrote:
> On May 25, 1:58 pm, Fab <fabien.mauss...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>> On 05/25/2012 02:50 PM, Sir Loin Steak wrote:
>
>>> Hi all
>
>>> I have a lot of numbers that have high precision (such as 401.4798584)
>>> and I am trying to find what sort of array to use to store these
>>> values. Can anyone help? I've tried floats, doubles etc, and none keep
>>> the precision to more than 5 d.p. Am I missing something obvious, or
>>> is what I'm after impossible?!!
>
>> What do you mean with "keep" the precision?
>
>> IDL> f = 401.4798584
>> IDL> d = 401.4798584d
>> IDL> print, f
>> 401.480
>> IDL> print, d
>> 401.47986
>> IDL> print, f, FORMAT='(F12.8)'
>> 401.47985840
>> IDL> print, d, FORMAT='(F12.8)'
>> 401.47985840
>
>> http://www.idlcoyote.com/math_tips/sky_is_falling.html
>
>> Cheers
>
> Sorry, what I meant was I want to write the data to a file for another
> program to read, but the data were always output in the form 401.480.
> I never thought about specifying with a format statement! I'll give it
> a go now.
>
> Thanks for the help.
I think you missed the point of the previous post. When you declare
something as a double, IDL keeps that precision but doesn't print it
out when you say print. You need to use a formatted print statement
to "see" all those extra digits.
The bottom line is, they're there. You just aren't seeing them. And
do read that article by Fanning.
|
|
|