[Thread Prev][Thread Next][Index]
Re: [ferret_users] listing an integer number to a file
Hi Ansley,
Thank you very much for your reply!!!
Assigning integer to a string variable solved my problem.
It is also very useful to append string variables.
Thank you for the trick.
Murat
> Hi Murat,
> Ryo's quite right about the reason you lose the last digits of the
> floating-point variable.
>
> Here's one idea. If you're not working with the numbers as numeric
> values, but just assigning them in Ferret commands, you could put it
> into a string variable:
>
> yes? let intnum = "200710120300"
> yes? list/format=(a)/file=out.txt/nohead/clobber intnum
> yes? sp cat out.txt
> 200710120300
>
> Depending on what you're trying to do, you may be able to work with your
> data using string functions. For instance you could define string
> variables with years, months, days, etc, and use the STRCAT function to
> append these into single string variables
>
> yes? let datestr = {"20070215","20071115", "20080115"}
> yes? let timestr = {"1115", "1200", "0112"}
> yes? let outstr = strcat(datestr, timestr)
> yes? list/format=(a)/file=out.txt/nohead/clobber outstr
> LISTing to file out.txt
>
> yes? sp cat out.txt
> 200702151115
> 200711151200
> 200801150112
>
>
> Ryo Furue wrote:
>> Hi Murat,
>>
>> | I am trying to save an integer number to a file.
>> |
>> | yes? let intnum = 200710120300
>> | yes? list/file=out.txt/nohead/clobber/format=(f20.0) intnum
>> |
>> |
>> | however, the out.txt file include below value, instead of intnum.
>> | more out.txt
>> | 200710127616.
>>
>> I think a variable in Ferret is a single-precision floating point
>> number, which can accommodate only 5-7 decimal digits. Your number
>> has 12 decimal places. Even the standard integer (32-bit) can't
>> handle it. (Its maximum is 2147483647.)
>>
>> I don't have a good idea to solve your problem. The best I can
>> think of right now is something along the lines of
>>
>> yes? let a = 1234
>> yes? let b = 5678
>> yes? list/format=(f5.0,f5.0) a,b
>> . . . . . .
>> 1234.5678.
>>
>> and remove the decimal points afterwards outside Ferret (using
>> a shell script or something).
>>
>> Regards,
>> Ryo
>>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Privacy Policy | Disclaimer | Accessibility Statement