GLib.Math
Description:
Binding to the C standard library's maths functions
When compiling binary output with valac
and some libc
implementations, such as GNU's libc
, you will need
to pass through the math library linker flags, -lm
, if a function is not found. For example:
valac -X -lm my_maths_program.vala
Content:
Constants:
- public const double E
The base of natural logarithms.
- public const double LN10
- public const double LN2
- public const double LOG_2_BASE_10
- public const double PI
The value of pi (ratio of circle's circumference to its diameter).
- public const double PI_2
- public const double PI_4
- public const double SQRT2
Functions:
- public double acos (double x)
Calculates the arc cosine of
x
. - public float acosf (float x)
Calculates the arc cosine of
x
. - public double acosh (double x)
Calculates the inverse hyperbolic cosine of
x
. - public float acoshf (float x)
Calculates the inverse hyperbolic cosine of
x
. - public double asin (double x)
Calculates the arc sine of
x
. - public float asinf (float x)
Calculates the arc sine of
x
. - public double asinh (double x)
Returns the inverse hyperbolic sine of
x
, that is the value whose hyperbolic sine isx
. - public float asinhf (float x)
Returns the inverse hyperbolic sine of
x
, that is the value whose hyperbolic sine isx
. - public double atan (double x)
Calculates the arc tangent of
x
. - public double atan2 (double y, double x)
Calculates the arc tangent of the two variables
x
andy
. - public float atan2f (float y, float x)
Calculates the arc tangent of the two variables
x
andy
. - public float atanf (float x)
Calculates the arc tangent of
x
. - public double atanh (double x)
Returns the inverse hyperbolic tangent of
x
. - public float atanhf (float x)
Returns the inverse hyperbolic tangent of
x
. - public double cbrt (double x)
Returns the (real) cube root of x.
- public float cbrtf (float x)
Returns the (real) cube root of
x
. - public double ceil (double x)
Rounds
x
up to the nearest integer. - public float ceilf (float x)
Rounds
x
up to the nearest integer. - public double copysign (double x, double y)
Returns a value whose absolute value matches that of
x
, but whose sign bit matches that ofy
. - public float copysignf (float x, float y)
Returns a value whose absolute value matches that of
x
, but whose sign bit matches that ofy
. - public double cos (double x)
Returns the cosine of
x
. - public float cosf (float x)
Returns the cosine of
x
. - public double cosh (double x)
Returns the hyperbolic cosine of
x
. - public float coshf (float x)
Returns the hyperbolic cosine of
x
. - public double drem (double x, double y)
Computes the remainder of dividing x by y.
- public float dremf (float x, float y)
Computes the remainder of dividing
x
byy
. - public double erf (double x0)
Returns the error function of
x0
. - public double erfc (double x0)
Returns the complementary error function of
x0
, that is1.0 - erf(x0)
. - public float erfcf (float x0)
Returns the complementary error function of
x0
, that is1.0 - erf(x0)
. - public float erff (float x0)
Returns the error function of x0.
- public double exp (double x)
Returns the value of the base of natural logarithms raised to the power of
x
. - public double exp10 (double x)
Returns the value of 10 raised to the power of
x
. - public float exp10f (float x)
Returns the value of 10 raised to the power of
x
. - public double exp2 (double x)
Returns the value of 2 raised to the power of
x
. - public float exp2f (float x)
Returns the value of 2 raised to the power of
x
. - public float expf (float x)
Returns the value of the base of natural logarithms raised to the power of
x
. - public double expm1 (double x)
Returns a value equivalent to
exp(x) - 1
. - public float expm1f (float x)
Returns a value equivalent to
exp(x) - 1
. - public double fabs (double x)
Returns the absolute value.
- public float fabsf (float x)
Returns the absolute value.
- public double fdim (double x, double y)
Returns
max(x - y, 0)
. - public float fdimf (float x, float y)
Returns
max(x - y, 0)
. - public int finite (double value)
Returns the value of not-a-number (NaN) checking.
- public int finitef (float value)
Returns the value of not-a-number ( float.NAN) checking.
- public double floor (double x)
Rounds
x
down to the nearest integer. - public float floorf (float x)
Rounds
x
down to the nearest integer. - public double fma (double x, double y, double z)
Computes
x * y + z
. - public float fmaf (float x, float y, float z)
Computes
x * y + z
. - public double fmax (double x, double y)
Returns the larger value of
x
andy
. - public float fmaxf (float x, float y)
Returns the larger value of
x
andy
. - public double fmin (double x, double y)
Returns the smaller value of
x
andy
. - public float fminf (float x, float y)
Returns the smaller value of
x
andy
. - public double fmod (double x, double y)
Computes the remainder of dividing
x
byy
. - public float fmodf (float x, float y)
Computes the remainder of dividing
x
byy
. - public double frexp (double x, out int exponent)
Split the number
x
into a normalized fraction and an exponent. - public float frexpf (float x, out int exponent)
Split the number
x
into a normalized fraction and an exponent. - public double gamma (double x0)
Computes the natural logarithm of the Gamma function.
- public float gammaf (float x0)
Computes the natural logarithm of the Gamma function.
- public double hypot (double x, double y)
Returns the length of the hypotenuse of a right-angle triangle with sides of length
x
andy
, or the distance of the point(x,y)
from the origin. - public float hypotf (float x, float y)
Returns the length of the hypotenuse of a right-angle triangle.
- public int ilogb (double x)
Returns the exponent part of their argument as a signed integer.
- public int ilogbf (float x)
Returns the exponent part of their argument as a signed integer.
- public int isinf (double value)
- public int isinff (float value)
Returns the value of infinity checking.
- public int isnan (double value)
- public int isnanf (float value)
Returns a non-zero value if
value
is not-a-number ( float.NAN). - public double j0 (double x0)
Returns Bessel function of
x0
of the first kind of order 0. - public float j0f (float x0)
Returns Bessel function of
x0
of the first kind of order 0. - public double j1 (double x0)
Returns Bessel function of
x0
of the first kind of order 1. - public float j1f (float x0)
Returns Bessel function of
x0
of the first kind of order 1. - public double jn (int x0, double x1)
Returns Bessel function of
x
of the first kind of ordern
. - public float jnf (int x0, float x1)
Returns Bessel function of
x
of the first kind of ordern
. - public double ldexp (double x, int exponent)
Returns the result of multiplying the floating-point number
x
by 2 raised to the powerexponent
. - public float ldexpf (float x, int exponent)
Returns the result of multiplying the floating-point number
x
by 2 raised to the powerexponent
. - public double lgamma (double x0)
Returns the natural logarithm of the absolute value of the Gamma function.
- public double lgamma_r (double x0, out int signgamp)
Returns the natural logarithm of the absolute value of the Gamma function.
- public float lgamma_rf (float x0, out int signgamp)
Returns the natural logarithm of the absolute value of the Gamma function.
- public float lgammaf (float x0)
Returns the natural logarithm of the absolute value of the Gamma function.
- public int64 llrint (double x)
Rounds it's argument to the nearest integer value, using the current rounding direction.
- public int64 llrintf (float x)
Rounds it's argument to the nearest integer value, using the current rounding direction.
- public int64 llround (double x)
Rounds it's argument to the nearest integer value, rounding away from zero, regardless of the current rounding direction.
- public int64 llroundf (float x)
Rounds it's argument to the nearest integer value, rounding away from zero, regardless of the current rounding direction.
- public double log (double x)
Returns the natural logarithm of
x
. - public double log10 (double x)
Returns the base 10 logarithm of
x
. - public float log10f (float x)
Returns the base 10 logarithm of
x
. - public double log1p (double x)
Returns a value equivalent to
log(1 + x)
. - public float log1pf (float x)
Returns a value equivalent to
log(1 + x)
. - public double log2 (double x)
Returns the base 2 logarithm of
x
. - public float log2f (float x)
Returns the base 2 logarithm of
x
. - public double logb (double x)
Extracts the exponent of
x
and returns it as a floating-point value. - public float logbf (float x)
Extracts the exponent of x and returns it as a floating-point value.
- public float logf (float x)
Returns the natural logarithm of
x
. - public long lrint (double x)
Rounds it's argument to the nearest integer value, using the current rounding direction.
- public long lrintf (float x)
Rounds it's argument to the nearest integer value, using the current rounding direction.
- public long lround (double x)
Rounds it's argument to the nearest integer value, rounding away from zero, regardless of the current rounding direction.
- public long lroundf (float x)
Rounds it's argument to the nearest integer value, rounding away from zero, regardless of the current rounding direction.
- public double modf (double x, out double iptr)
Breaks the argument
x
into an integral part and a fractional part, each of which has the same sign asx
. - public float modff (float x, out float iptr)
Breaks the argument
x
into an integral part and a fractional part. each of which has the same sign asx
. - public double nan (string tagb)
Returns a representation (determined by
tagb
) of a quiet double.NAN. - public float nanf (string tagb)
Returns a representation (determined by
tag
) of a quiet float.NAN. - public double nearbyint (double x)
Rounds argument
x
to an integer value in floating point format, using the current rounding direction and without raising the inexact exception. - public float nearbyintf (float x)
Rounds argument
x
to an integer value in floating point format, using the current rounding direction and without raising the inexact exception. - public double nextafter (double x, double y)
Returns the next representable neighbor of
x
in the direction towardsy
. - public float nextafterf (float x, float y)
Returns the next representable neighbor of
x
in the direction towardsy
. - public double nexttoward (double x, double y)
- public float nexttowardf (float x, double y)
- public double pow (double x, double y)
Returns the value of
x
raised to the power ofy
. - public double pow10 (double x)
Returns the value of 10 raised to the power of
x
. - public float pow10f (float x)
Returns the value of 10 raised to the power of
x
. - public float powf (float x, float y)
Returns the value of
x
raised to the power ofy
. - public double remainder (double x, double y)
Computes the remainder of dividing
x
byy
. - public float remainderf (float x, float y)
Computes the remainder of dividing
x
byy
. - public double remquo (double x, double y, out int quo)
Computes the remainder and part of the quotient upon division of
x
byy
. - public float remquof (float x, float y, out int quo)
Computes the remainder and part of the quotient upon division of
x
byy
. - public double rint (double x)
Rounds it's argument to an integer value in floating point format, using the current rounding direction and with raising the inexact exception.
- public float rintf (float x)
Rounds it's argument to an integer value in floating point format. using the current rounding direction and with raising the inexact exception.
- public double round (double x)
Rounds argument
x
to the nearest integer, but round halfway cases away from zero, (regardless of the current rounding direction), instead of to the nearest even integer like rint. - public float roundf (float x)
Rounds argument
x
to the nearest integer, but round halfway cases away from zero (regardless of the current rounding direction), instead of to the nearest even integer like rint. - public double scalb (double x, double n)
Multiplies
x
by 2 to the powern
. - public float scalbf (float x, float n)
Multiplies
x
by 2 to the powern
. - public double scalbln (double x, long n)
This function is equivalent to GLib.Math.ldexp.
- public float scalblnf (float x, long n)
This function is equivalent to Math.ldexp.
- public double scalbn (double x, int n)
Multiplies it's first argument
x
by 2 to the powern
. - public float scalbnf (float x, int n)
Multiplies it's first argument
x
by 2 to the powern
. - public double significand (double x)
Returns the mantissa of
x
scaled to the range[1,2]
. - public float significandf (float x)
Returns the mantissa of
x
scaled to the range[1,2]
. - public double sin (double x)
Returns the sine of
x
. - public void sincos (double x, out double sinx, out double cosx)
computes both sine and cosine of
x
at the same time. - public void sincosf (float x, out float sinx, out float cosx)
Computes both sine and cosine of
x
at the same time. - public float sinf (float x)
Returns the sine of
x
, wherex
is given in radians. - public double sinh (double x)
Returns the hyperbolic sine of
x
. - public float sinhf (float x)
returns the hyperbolic sine of
x
. - public double sqrt (double x)
Returns the non-negative square root of
x
. - public float sqrtf (float x)
Returns the non-negative square root of
x
. - public double tan (double x)
Returns the tangent of
x
, wherex
is given in radians. - public float tanf (float x)
Returns the tangent of
x
. - public double tanh (double x)
returns the hyperbolic tangent of
x
. - public float tanhf (float x)
Returns the hyperbolic tangent of
x
. - public double tgamma (double x0)
Returns the value of Gamma function for the argument
x0
. - public float tgammaf (float x0)
Returns the value of Gamma function for the argument
x0
. - public double trunc (double x)
Rounds argument
x
to the nearest integer not larger in absolute value. - public float truncf (float x)
Rounds argument
x
to the nearest integer not larger in absolute value. - public double y0 (double x0)
Returns Bessel function of
x0
of the second kind of order 0. - public float y0f (float x0)
Returns Bessel function of x0 of the second kind of order 0.
- public double y1 (double x0)
Returns Bessel function of
x0
of the second kind of order 1. - public float y1f (float x0)
Returns Bessel function of
x0
of the second kind of order 1. - public double yn (int x0, double x1)
Returns Bessel function of
x1
of the second kind of orderx0
. - public float ynf (int x0, float x1)
Returns Bessel function of
x1
of the second kind of orderx0
.