[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unwrap modulo 2pi

> 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:

Converts input to the nearest integer.

result = NINT(x)

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

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

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

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