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

Home » Public Forums » archive » Re: Integer - decimal help
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: Integer - decimal help [message #67722 is a reply to message #67721] Tue, 25 August 2009 03:31 Go to previous messageGo to previous message
Nusret Sevinç is currently offline  Nusret Sevinç
Messages: 8
Registered: March 2009
Junior Member
On 25 Ağustos, 12:28, Maarten <maarten.sn...@knmi.nl> wrote:
> On Aug 25, 11:14 am, Nusret Sevinç <nusretsev...@gmail.com> wrote:
>
>> I don't know how to read the integer and decimal parts of a number
>> separately . For example:
>
>> I have a number: x=34.75
>
>> I would like to read the integer part and decimal part separately:
>> a=34, b=75(or .75)
>
Thanks for your answer Marteen. But these solutions didn't work, I
think I missed to say that my 'x' number is a float array with size of
1461.



> Many possiblities:
>
> ; read x as float, and peel parts apart:
> x = 34.75
> a = floor(x)
> b = x - a

When I tried this one, it gives both a and b zero.
>
> ; read x as string, and use strsplit:
> x = '34.75'
> parts = strsplit(x, ".", /extract)
> a = long(parts[0])
> b = long(parts[1])
>
> Maarten

When I tried to use this one, I changed my float array 'x' into string
array, and here is the error I got:

IDL> parts=strsplit(nu,".",/extract)
% Compiled module: STRSPLIT.
% STRTOK: Expression must be a scalar or 1 element array in this
context: STRINGIN.
% Error occurred at: STRSPLIT 32 /usr/local/rsi/idl_6.3/lib/
strsplit.pro
% $MAIN$

Is there any other way for arrays?
Thanks in advance,
Nusret
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Speed-up of code
Next Topic: Digits in IDL

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

Current Time: Wed Oct 08 18:24:09 PDT 2025

Total time taken to generate the page: 0.00421 seconds