Yongzhou,
As Dave pointed out, it is better you use double to represent the date.
Or you can use NCL's newly added data type: int64, or uint64.
For example, you may have:
s = "20080901000000"
i64 = toint64(s)
ui64 = touint64(s)
d = todouble(s)
print(i64)
print(ui64)
print(d)
will give you:
Variable: i64
Type: int64
Total Size: 8 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 20080901000000
Variable: ui64
Type: uint64
Total Size: 8 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 20080901000000
Variable: d
Type: double
Total Size: 8 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 20080901000000
You may also noticed there are new convert functions as well.
Hope this help,
Wei Huang
huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924
On Jun 9, 2010, at 5:41 PM, Li, Yongzuo wrote:
> Hi,
>
> I have a script to test stringtofloat
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> begin
>
> s = "2008090100"
> f = stringtofloat(s)
> i = stringtoint(s)
>
> print("string= "+s)
> print("float= "+f)
> print("int= "+i)
>
> end
>
> The output for float is wrong
>
> (0) string= 2008090100
> (0) float= 2.00809e+09
> (0) int= 2008090100
>
> Yongzuo
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jun 9 21:39:49 2010
This archive was generated by hypermail 2.1.8 : Fri Jun 11 2010 - 09:33:24 MDT