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

Home » Public Forums » archive » Re: unwrap modulo 2pi
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: unwrap modulo 2pi [message #23697 is a reply to message #23649] Fri, 09 February 2001 00:42 Go to previous messageGo to previous message
Wim Bouwman is currently offline  Wim Bouwman
Messages: 8
Registered: September 1997
Junior Member
> Just curious, how does NINT do the rounding? In IDL there are FLOOR,
> CEIL and ROUND which have well-behaved rounding properties (round up,
> down and to-nearest, respectively). The well-known LONG function is
> not consistent depending on the sign of its argument.

A copy of the NINT-page of the pv-wave manual:

NINT
Converts input to the nearest integer.

Usage
result = NINT(x)

Input Parameters
x : A scalar or array of any PV-WAVE variable type, usually float or double.

Keywords
Long : If present and non-zero, NINT returns a long instead of a short (FIX)
integer.

Returned Value
result : The nearest integer to the input value.

Discussion
Instead of truncating the input (as FIX does), first the input is rounded by
adding or subtracting 0.5 (depending on whether the input is greater or less
than zero), and then it is truncated.
If the input is out of the range of integers (for example, if you pass in
1.0d33), an error message will result and NINT returns garbage.
Add �0.5 to the input and convert that to a short integer using FIX. If the
Long keyword is used, it's converted via long. If the input is a FIX, then it's
just passed back. If it's a long, it's also passed back. Strings are converted
to bytes before the rounding. In the case of complex values, their magnitude is
taken. Structures are not allowed.

--

Dr. Wim G. Bouwman phone (++31) (0)15 2786775
Interfacultair Reactor Instituut fax (++31) (0)15 2788303
Technische universiteit Delft w.g.bouwman@iri.tudelft.nl
Mekelweg 15 http://www.iri.tudelft.nl/~bouwman
2629 JB Delft The Netherlands
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL programmers wanted
Next Topic: Re: True Color, but !d.table_size eq 64?

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

Current Time: Sun Oct 12 22:18:05 PDT 2025

Total time taken to generate the page: 2.31893 seconds