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

Home » Public Forums » archive » number of decimals?
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: number of decimals? [message #41987 is a reply to message #41751] Thu, 09 December 2004 07:23 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Thu, 2004-12-09 at 08:56 +0000, Christopher Lee wrote:
> In article <1102567764.693437.32940@c13g2000cwb.googlegroups.com>,
> "Unknown" <ytyourclothes@p.zapto.org> wrote:
>
>> ...
>> IDL> printf,unit,f,format='(10f9.2)'
>> but that'll introduce additional spaces wherever a number is smaller
>> than 10000. So a typical line might look like this: 123.45 678.23
>> 1.23 12345.67 ... etc
>> But what I want is
>> 123.45 678.23 1.23 12345.67 ...
>> What I'm trying to do would be written in C somewhat like this: "%.2f
>> %.2f %.2f", i.e. a floating point number with two decimals.
>> ...
>> Y. T.
>
> No tricks, but you can use the C format codes in IDL
>
> f=randomn(seed, 10,10)
> print, format='(10(%"%0.5f "))',f[0,*]
>
> That will write out floating point numbers with 5 decimal places and a
> single space between each number. Your emacs loving
> friends will disown you for breaking their copy-rectangle-to-register,
> but I think it's what you want.


For most versions of IDL, your example doesn't work works because 6 is
the default number of decimal places for "natural length" floats, which
is all the "%0.5" requests (i.e. you could have written %0.100). It's
the same with normal format codes, in IDL 6.0:

IDL> print,FORMAT='(2(F0.2,:," "))',!PI,!PI^4
3.141593 97.409103

Starting with IDL6.1, IDL finally respects width "0" formats:

IDL 6.1:

IDL> print,FORMAT='(2(F0.2,:," "))',!PI,!PI^4
3.14 97.41

I hadn't appreciated that you could mix FORTRAN style and C-style format
codes, which could be very useful.

JD
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: READ_ASCII - accessing data from structures
Next Topic: To PVM or not to PVM

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

Current Time: Fri Oct 10 22:36:50 PDT 2025

Total time taken to generate the page: 0.56040 seconds