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

Home » Public Forums » archive » Re: IDL strplit : split a decimal number
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: IDL strplit : split a decimal number [message #40015 is a reply to message #40014] Wed, 07 July 2004 03:37 Go to previous message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
> For example, let's take A = 147.123456789d
> I need to make an 2D integer array called B, containing the two parts
> of A seperated by the dot ... B(0) = 147 and B(1) = 123456789 ... with

<snip>

> Maybe I shouldn't use the STRSPLIT function to do this?

How about not using strsplit?

IDL> a=123.45434362d

IDL> print, floor(a)
123

IDL> print, a-floor(a)
0.45434362

IDL> print, (a-floor(a))*1e8
45434362.

so b[0]=long(floor(a)) and
b[1]=long((a-floor(a))*1e8)

Note - I've used longs rather than ints as the double precision will be
larger than the point where ints go round again (~32k).

Ben

Blimey. And to think that a year ago I was worried about the sky falling
in with doubles and floats.

--
Ben Panter, Edinburgh
My name (no spaces)@bigfoot which is a com.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Rebinning large array
Next Topic: Re: IDL strplit : split a decimal number -errata

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

Current Time: Thu Oct 09 17:23:19 PDT 2025

Total time taken to generate the page: 0.32191 seconds