lroundf


Description:

public long lroundf (float 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 float.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 float to long:

public static int main (string[] args) {
// Output:
// ``lroundf (0.3f) = 0f``
// ``lroundf (0.4f) = 0f``
// ``lroundf (0.5f) = 1f``
// ``lroundf (0.6f) = 1f``

print ("lroundf (%.1lff) = %lif\n", 0.3f, Math.lroundf (0.3f));
print ("lroundf (%.1lff) = %lif\n", 0.4f, Math.lroundf (0.4f));
print ("lroundf (%.1lff) = %lif\n", 0.5f, Math.lroundf (0.5f));
print ("lroundf (%.1lff) = %lif\n", 0.6f, Math.lroundf (0.6f));

return 0;
}

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

Parameters:

x

A numeric value.


Namespace: GLib.Math
Package: glib-2.0