Re: Possible bug in "tostring" function

From: David Jones <jonesd647_at_nyahnyahspammersnyahnyah>
Date: Fri Jul 04 2014 - 06:30:32 MDT

Thank you very much for your answer. For my purposes, using tostri=
ng_with_format(b, "%8.5f") works better. This is a very helpful to=
ol, which I never knew about before. It might be helpful to others to list =
it in the online documentation, as it does not appear to be listed in the o=
nline alphabetical listing of functions or anywhere else on the NCL site, u=
nless I'm mistaken. Best regards, Dave. On Friday, July 4=
, 2014 12:25:43 AM, Wei Huang <huangwei@ucar.edu> wrote: Dave,=

f" to convert float to string, and for this case, the last digit is at th=
e border of its precision. You may try to use a double which works better=
 at this situation. Or you may try:  bsf = tostring_with_format(=
b, "%8.5f")  print(bsf) Regards, Wei =

erful software that is NCL. I think it's wonderful. > > > >Secondl=
y, I'd like to report that I may have found a bug in the tostring function.=
.. > >When I round a float using decimalPlaces and then convert that fl=
oat to a string, the string matches the unrounded number instead of the rou=
nded one. > >ncl 0> a=32.328739 >ncl 1> load "$NCARG_ROOT/lib/ncarg=
/nclscripts/csm/contributed.ncl" >ncl 2> b=decimalPlaces(a,5,True) >n=
cl 3> print(b) > >Variable: b >Type: float >Total Size: 4 bytes >=
            1 values >Number of Dimensions: 1 >Di=
mensions and sizes:   [1] >Coordinates: >(0)     32.32874=

e: string >Total Size: 8 bytes >            1 val=
ues >Number of Dimensions: 1 >Dimensions and sizes:   [1] >Coordi=
nates: >(0)     32.328739 > >This behavior only seems to =
happen with certain numbers, but I can't quite see a pattern as to which=
 numbers are affected. I only need to round to 5 decimal places, so I'm =
not sure if other roundings can be similarly affected. > >Could you=
 please clarify is this is a bug, or if I've somehow misunderstood the c=
orrect usage of the function. For further information, I'm using ncl ver=
sion 6.1.2 on a 64-bit Linux system (I installed the Debian gcc455 binar=
y). > > >With best regards, >Dave. > >_________________________=
______________________ >ncl-talk mailing list >List instructions, subsc=
riber 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 Fri Jul 04 12:30:40 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT