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

Home » Public Forums » archive » Re: Excluding Decimal Places in the Values of a Variable
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: Excluding Decimal Places in the Values of a Variable [message #83204] Tue, 19 February 2013 12:32 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 02/14/13 15:55, David Fanning wrote:
>
> I would do it this way:
>
> IDL> x=[[1.35679, 2.65487], [3.65789, 4.56455]]
> IDL> x = Fix(x*1000)/1000.
>
> Cheers,
>
> David

How's this for a more complicated answer:

FUNCTION SetDP, x, n, double=double
num = 10L^n
rnum = KEYWORD_SET(double) ? DOUBLE(num) : FLOAT(num)
RETURN, FLOOR(x*num)/rnum
END

IDL> x=[[1.35679, 2.65487], [3.65789, 4.56455]]
IDL> print, x
1.35679 2.65487
3.65789 4.56455
IDL> print, SetDP(x,2), format='(f18.15)'
1.350000023841858
2.650000095367432
3.650000095367432
4.559999942779541
IDL> print, SetDP(x,2,/double), format='(f18.15)'
1.350000000000000
2.650000000000000
3.650000000000000
4.560000000000000


:o)


Sorry....

cheers,

paulv
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: cghistoplot: getting histdata values without any plotting?
Next Topic: Re: differences among map_proj_image, map_image and map_patch

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

Current Time: Fri Oct 10 02:03:17 PDT 2025

Total time taken to generate the page: 0.56045 seconds