lround


Description:

public long lround (double x)

Rounds it's argument to the nearest integer value, rounding away from zero, regardless of the current rounding direction.

Note:

Remember to link the math library: valac -X -lm ...

If x is infinite or double.NAN, or if the rounded value is outside the range of the return type, the numeric result is unspecified.

A domain error may occur if the magnitude of x is too large.

Example: Round double to long:

public static int main (string[] args) {
// Output:
// ``lround (1.3) = 1``
// ``lround (1.4) = 1``
// ``lround (1.5) = 2``
// ``lround (1.6) = 2``

print ("lround (%.1lf) = %li\n", 1.3, Math.lround (1.3));
print ("lround (%.1lf) = %li\n", 1.4, Math.lround (1.4));
print ("lround (%.1lf) = %li\n", 1.5, Math.lround (1.5));
print ("lround (%.1lf) = %li\n", 1.6, Math.lround (1.6));

return 0;
}

valac --pkg glib-2.0 -X -lm GLib.Math.lround.vala

Parameters:

x

A numeric value.


Namespace: GLib.Math
Package: glib-2.0