appending to column [message #61378] |
Wed, 16 July 2008 09:02  |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
Folks
I have a float array that first column is the integer part and second
column is the decimal part of that number. How I can append this to
column to get one column of that float number. For example:
[123,456]------> 123.456
……… ……….
Thanks
Cheers
|
|
|
Re: appending to column [message #61455 is a reply to message #61378] |
Wed, 16 July 2008 11:22  |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
"Jean H" <jghasban@DELTHIS.ucalgary.ANDTHIS.ca> wrote in message
news:g5lb22$inp$1@news.ucalgary.ca...
>> IDL> print,a
>> 0 1
>> 2 3
>> 4 311
>> IDL> print,a[0,*] +
>> float(a[1,*])/10^strlen(strcompress(string(a[1,*]),/rem))
>> 0.100000
>> 2.30000
>> 4.31100
>>
>>
>> Cheers,
>> bob
>
> While using strings, we can make it more efficiently. There is no need to
> do any division, get the length or anything:
>
> IDL> help, 1 + float('0.'+strtrim(234,2))
> <Expression> FLOAT = 1.23400
>
> Jean
It is always a trade-off. Do you want an answer fast,
or do you want an answer that is right?
lol
Cheers,
bob
|
|
|
Re: appending to column [message #61458 is a reply to message #61378] |
Wed, 16 July 2008 10:54  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jean H writes:
> 1) get the number of digits for the decimal part
This is the part that's handy to know. I could have
saved myself a hell of a lot of effort in the past, had
I known about this.
I shouldn't have taught myself how to write programs.
This is probably taught in Programming 101 today. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: appending to column [message #61460 is a reply to message #61378] |
Wed, 16 July 2008 10:48  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On Jul 16, 11:27 am, Jean H
> IDL> help, 1 + float('0.'+strtrim(234,2))
> <Expression> FLOAT = 1.23400
Nifty.
Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
|
|
|