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

Home » Public Forums » archive » Re: Converting Doubles to Strings
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: Converting Doubles to Strings [message #46153 is a reply to message #46149] Mon, 07 November 2005 11:53 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
David Fanning wrote:

> Folks,
>
> I've run into an interesting problem. I have a double precision
> number that I wish to convert to a string (so I can put it into
> a text widget, for example). I don't know ahead of time how many
> significant digits will be in this number. The number could
> look like this 45.6, or this 123456789.123456789, or this
> -22.1234567890. If it looks like the latter number, I am
> having a very hard time converting it to a string. For example,
> this doesn't work:
>
> IDL> v = String(-22.1234567890, Format='(D0)')
> IDL> Print, v
> -22.123457
>

David
the sky is falling down

Why do you think thats 22.1234567890 is of type double. This is float!

Probably it's only a type mismatch in this example here.

I prefer the 'G' format

IDL> print, String(-22.1234567890D, Format='(G)')
-22.12345678900000

instead of
IDL> print, String(-22.1234567890D, Format='(D)')
-22.1234567889999987


cheers
Reimar





> Is this a bug in IDL? Or am I overlooking something?
>
> Cheers,
>
> David
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Displaying three images simultaneously (using Object Graphics)
Next Topic: Specifying Log Axis Tick Marks

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

Current Time: Thu Oct 09 20:44:45 PDT 2025

Total time taken to generate the page: 0.74342 seconds