Request for help on math_format function

Charles Seman Charles.Seman at NOAA.GOV
Thu Jan 17 18:54:22 EST 2008


Robert,

Here are some results from a script constructed following your code
(attached):

ga-> test_math_format.gs
math_format("%02.0g",5) = 05
math_format("%02.1g",5) = 05
math_format("%02.2g",5) = 05
math_format("%2.0g",5) =  5
math_format("%03.2d",5) =  00
math_format("%02.0g",5.0) = 05
math_format("%02.1g",5.0) = 05
math_format("%03.1g",5.0) = 005
math_format("%03.2d",5.0) =  00
math_format("%02.0g",5.1) = 05
math_format("%02.1g",5.1) = 05
math_format("%02.0f",5.1) = 05
math_format("%02.1f",5.1) = 5.1
math_format("%02.2f",5.1) = 5.10
math_format("%2.2f",5.1) = 5.10
math_format("%03.2f",5.1) = 5.10
math_format("%03.2d",5.1) = 1717986918
math_format("%02.2d",5.1) = 1717986918
math_format("%02.0d",5.1) = 1717986918

I hope this helps,
Chuck

Robert F Esswein wrote:
> Dear Grads users -
>
> The "math_format" function is not working for me the way I expect (and
> want) it
> to. For example, I expect math_format("%02.2d",5) to be "05".
> But Grads is giving me "00".
> Is there any way I can get this to work the same as C printf, etc.
>
> A test script:
>
> num = 5
> say 'math_format("%02.2d",' num ') = ' math_format("%02.2d",num)
> quit
>
> Here is the output from Grads (some lines deleted):
>
> c 217% grads -clb 'run fmttest'
> Grid Analysis and Display System (GrADS) Version 1.9b4
> Config: v1.9b4 32-bit little-endian readline sdf/xdf hdf-sds netcdf
> lats printim
> Running in Batch mode
> math_format("%02.2d",5) = 00
>
> My system is
> Linux c.arc.nasa.gov 2.6.20-2936.fc7xen #1 SMP Fri Sep 21 11:56:20 EDT
> 2007 x86_64 x86_64 x86_64 GNU/Linux
> Fedora release 7 (Moonshine)
>
> Grads was installed from grads-bin-1.9b4-linuxRHE3.tar.gz
>
> Thanks,
> Bob

--

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 U.S. Department of Commerce / NOAA / OAR
 Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
 201 Forrestal Road                              fax: (609) 987-5063
 Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_math_format.gs
Url: http://gradsusr.org/pipermail/gradsusr/attachments/20080117/7f55ed34/attachment.pl 


More information about the gradsusr mailing list