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 #67723 is a reply to message #67722] Tue, 25 August 2009 02:28 Go to previous messageGo to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
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)

Many possiblities:

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

; read x as string, and use strsplit:
x = '34.75'
parts = strsplit(x, ".", /extract)
a = long(parts[0])
b = long(parts[1])

Maarten
[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 17:29:47 PDT 2025

Total time taken to generate the page: 0.00413 seconds