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

Home » Public Forums » archive » String to Floating conversion
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
String to Floating conversion [message #80324] Mon, 28 May 2012 05:01 Go to next message
Baro is currently offline  Baro
Messages: 19
Registered: May 2012
Junior Member
Dear Friends

I am a new user of IDL. this time I am trying to read the data of this
type.

GRCOF2 0 0 0.100000000000E+01 0.000000000000E+00 0.0000E+00
0.0000E+00 20030301.0000 20030401.0000 nnnn
GRCOF2 1 0 0.000000000000E+00 0.000000000000E+00 0.0000E+00
0.0000E+00 20030301.0000 20030401.0000 nnnn
GRCOF2 2 0 -.484169137464E-03 0.000000000000E+00 0.1256E-10
0.0000E+00 20030301.0000 20030401.0000 ynnn

It is a GRACE satellite data

But I am getting error which says "Unable to convert String to
Floating"

Can any one help me in reading it, cause i have 122 files with 1895
lines for each, using IDL will simplify it a lot for me. I will wait
for your golden responses
Re: String to float [message #82675 is a reply to message #80324] Wed, 09 January 2013 11:47 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Fab writes:

>
> On 01/09/2013 08:10 PM, Gompie wrote:
>> Hi,
>> I have a string +2.64342987e+02 which I want to convert to float. Each digit is important so I dont want to loose any of them while type converting to float.
>>
>> print float(+2.64342987e+02) gives 264.343
>> print, double(+2.64342987e+02) gives 264.34299
>>
>> I want 264.342987
>>
>> Can anyone help.
>> Rgds
>> Gompie
>>
>
> http://www.idlcoyote.com/math_tips/sky_is_falling.html
>
> Let see if david is faster than me ;-)

Right!

IDL> n="+2.64342987e+02"
IDL> Print, Double(Str_Replace(n, 'e', 'd')), Format='(F0.6)'
264.342987

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: String to float [message #82676 is a reply to message #80324] Wed, 09 January 2013 11:13 Go to previous message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
On 01/09/2013 08:10 PM, Gompie wrote:
> Hi,
> I have a string +2.64342987e+02 which I want to convert to float. Each digit is important so I dont want to loose any of them while type converting to float.
>
> print float(+2.64342987e+02) gives 264.343
> print, double(+2.64342987e+02) gives 264.34299
>
> I want 264.342987
>
> Can anyone help.
> Rgds
> Gompie
>

http://www.idlcoyote.com/math_tips/sky_is_falling.html

Let see if david is faster than me ;-)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: String to float
Next Topic: Re: find missing elements in an array

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

Current Time: Wed Oct 08 13:49:50 PDT 2025

Total time taken to generate the page: 0.00556 seconds