comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » double precision?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Double precision [message #65776 is a reply to message #49718] Thu, 19 March 2009 12:21 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
plim.dreaming@gmail.com writes:

> Firstly say what is not the problem:
> the problem in not in comparing the numbers. I run one program which
> reads in the file and does some stuff to the numbers and then outputs
> to another file the selected array. Only after do I read in the
> selected array and perform separation comparisons. The problem
> already exists though in the output, since the numbers are truncated
> or rounded off there.
>
> And I really look at how I input the numbers and it seems fine. I
> read them in as double and then I print the numbers with 2f12.7 for
> example and they are still fully there, not truncated.
>
> I think the problem is in the printing to the output file.
>
> I have x,y and they are numbers such as 100.912498
> then I do a=strcompress(x)
> openw,1,'fds'
> printf,1,a

Ah, I see. Well, STRING (which is what StrCompress has
to call) is like PRINT: they have default formatting
rules. In particular, they format to eight significant
digits by default, unless they are told something different.

But, first of all. Why in the world are you converting these
to strings before you save them in the file!? That is a sure
way to get in trouble, as you have discovered. If you *had*
to do it, you could do it like this:

a = StrCompress(String(x, format='F0.10'), /Remove_all)

But a much better way would just be to write them into the
file without converting them to strings:

printf, x, Format='(F0.10)'

Or, whatever format it is you think you want.

Cheers,

David
--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Mac Widget Limitation?
Next Topic: Re: Span a graph across 2 spaces in a !P.MULTI environment?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Nov 29 03:08:16 PST 2025

Total time taken to generate the page: 0.13450 seconds