Re: About numeric precision

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 03 2012 - 15:19:05 MDT

To read double precision correctly, you should specify "double" in the
asciiread function. Also, DO NOT use the "new" statement before
reading the data. Just use a single command, like this:

xxx = asciiread (filename, (/a,b,/), "double")

--Dave

On Fri, Aug 3, 2012 at 12:35 PM, Cheung <zuibeidemei@126.com> wrote:
>
> Thanks!
>
> And if I read data from an ascii file, and I use the double array as
> xxx = new((/a,b,/),double)
> xxx = asciiread(x,x,x)
>
> will that happen again?
> or it depends on my data?
>
>
>
> At 2012-08-04 02:29:24,"Andrew Mai" <mai@ucar.edu> wrote:
>>On 08/03/2012 12:24 PM, Cheung wrote:
>>
>>> a = new(1,double)
>>> a = 19800103. (plus a point)
>>> print(a)
>>> a will be 19800104
>>
>>You have converted a 32-bit float to a 64-bit float. 32-bit floats only
>> have about 7 decimal places of accuracy.
>>
>>If, instead, you did:
>>
>>a = 19800103.d0
>>print(a)
>>
>>you would get 19800103 as you expect.
>>
>>Andy
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 3 15:19:15 2012

This archive was generated by hypermail 2.1.8 : Tue Aug 28 2012 - 09:22:09 MDT