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

Home » Public Forums » archive » Re: printing comma delimiters for float variables
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: printing comma delimiters for float variables [message #39595 is a reply to message #39586] Wed, 26 May 2004 18:04 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <40b4d5c2$1_4@marge.ic.sunysb.edu>,
Benjamin Hornberger <benjamin.hornberger@stonybrook.edu> wrote:

> I am still desperately trying to understand format codes ;-). Is there a
> way to print floating point variables with comma delimiters every 1000,
> e.g. 1,453,234.80?

I don't know how to do this with standard formats.

You can do it yourself, but it will be a little ugly.

IDL> x = 1453234.80D0
IDL> millions = LONG(x)/10^6
IDL> thousands = (LONG(x)/10^3) MOD 10^3
IDL> ones = LONG(x) MOD 10^3
IDL> fraction = LONG(100*(x - LONG(x)))
IDL> PRINT, millions, thousands, ones, fraction, $
IDL> FORMAT = "(I3,',',I3,',',I3,'.',I2)"
1,453,234.80

The trick will be handling numbers with different magnitudes.
(You need double precision above to get sufficient precision
to get the fraction right.)

Good luck, Ken Bowman
[Message index]
 
Read Message
Read Message
Previous Topic: extracting contours from IDL meshs
Next Topic: Uncaught PARTICLE_TRACE exception

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

Current Time: Wed Oct 08 19:34:21 PDT 2025

Total time taken to generate the page: 0.00346 seconds