llround
Description:
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 int64:
public static int main (string[] args) {
// Output:
// ``llround (1.3) = 1``
// ``llround (1.4) = 1``
// ``llround (1.5) = 2``
// ``llround (1.6) = 2``
print ("llround (%.1lf) = %" + int64.FORMAT + "\n", 1.3, Math.llround (1.3));
print ("llround (%.1lf) = %" + int64.FORMAT + "\n", 1.4, Math.llround (1.4));
print ("llround (%.1lf) = %" + int64.FORMAT + "\n", 1.5, Math.llround (1.5));
print ("llround (%.1lf) = %" + int64.FORMAT + "\n", 1.6, Math.llround (1.6));
return 0;
}
valac --pkg glib-2.0 -X -lm GLib.Math.llround.vala
Parameters:
x |
A numeric value. |
Namespace: GLib.Math
Package: glib-2.0