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

Home » Public Forums » archive » Re: rounding numbers
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: rounding numbers [message #82924] Wed, 23 January 2013 14:29
justinclouds is currently offline  justinclouds
Messages: 25
Registered: December 2012
Junior Member
On Wednesday, January 23, 2013 3:03:54 PM UTC-7, David Fanning wrote:
> justinclouds writes:
>
>
>
>>
>
>> I would like to be able to round up number of seconds since midnight as follows:
>
>>
>
>> round down 61825 to 61000
>
>> round up 61825 to 62000
>
>>
>
>> Is there an IDL function that does this and what is the syntax?
>
>
>
> IDL> Print, Floor(Float(61825) / 10^3) * 10^3
>
> 61000
>
> IDL> Print, Ceil(Float(61825) / 10^3) * 10^3
>
> 62000
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Thank you. This has been very helpful.
Re: rounding numbers [message #82925 is a reply to message #82924] Wed, 23 January 2013 14:03 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
justinclouds writes:

>
> I would like to be able to round up number of seconds since midnight as follows:
>
> round down 61825 to 61000
> round up 61825 to 62000
>
> Is there an IDL function that does this and what is the syntax?

IDL> Print, Floor(Float(61825) / 10^3) * 10^3
61000
IDL> Print, Ceil(Float(61825) / 10^3) * 10^3
62000

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: rounding numbers [message #82926 is a reply to message #82925] Wed, 23 January 2013 14:02 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
Since those are the same numbers, I'm not sure when to round up or round down. But I would try something like this:

num = 61825
base = 1000

diff = num MOD base

IF roundUp THEN roundedNum = num + base - diff
IF roundDown THEN roundedNum = num - diff

There are other ways to do it of course, but this would work.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: rounding numbers
Next Topic: Re: CgWindow and multiple plots

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

Current Time: Thu Oct 09 06:51:11 PDT 2025

Total time taken to generate the page: 0.80192 seconds