Returns the non-negative square root of x
.
Remember to link the math library: valac -X -lm ...
It fails and sets GLib.errno to EDOM, if x
is
negative.
Example: Square root (double):
public static int main (string[] args) {
// /----
// sqrt (4) = \/ 4 = 2
//
// Output: ``sqrt (4.0) = 2.000000``
double res = Math.sqrt (4.0);
print ("sqrt (4.0) = %lf\n", res);
return 0;
}
valac --pkg glib-2.0 -X -lm GLib.Math.sqrt.vala
x |
A numeric value. |