float
Object Hierarchy:
Description:
[ SimpleType ]
[ GIR ( name = "gfloat" ) ]
[ CCode ( cname = "gfloat" , default_value = "0.0F" , default_value_on_error = "-1.0F" , get_value_function = "g_value_get_float" , marshaller_type_name = "FLOAT" , set_value_function = "g_value_set_float" , type_id = "G_TYPE_FLOAT" ) ]
[ FloatingType ( rank = 1 ) ]
public struct float
Example: General samples:
public static int main (string[] args) {
float f1 = 0.3f;
float f2 = 3.4f;
// Output: ``0.300000, 3.400000``
print ("%f, %f\n", f1, f2);
return 0;
}
valac --pkg glib-2.0 float.vala
Content:
Constants:
- public const int DIG
Number of decimal digits that can be represented without losing precision
- public const float EPSILON
Difference between 1.0 and the next representable value for float
- public const float INFINITY
Indicates that the value is not representable by the underlying type
(positive or negative infinity)
- public const int MANT_DIG
Number of base RADIX
digits that can be represented without losing precision
- public const float MAX
Maximum value of float
- public const int MAX_10_EXP
Maximum positive integer such that 10 raised by power one more than that
integer is a normalized float
- public const int MAX_EXP
Maximum positive integer such that
RADIX raised by power one more than that integer is a normalized float
- public const float MIN
Minimum positive value of float, use -
float.MAX to get the minimum negative value
- public const int MIN_10_EXP
Minimum negative integer such that 10 raised by power one less than that
integer is a normalized float
- public const int MIN_EXP
Minimum negative integer such that
RADIX raised by power one less than that integer is a normalized float
- public const float NAN
Indicates that the value is not-a-number (NaN)
- public const int RADIX
The radix (integer base) used by the representation of all three floating-
point types
- public const int ROUNDS
Static methods:
- public static float max (float a, float b)
- public static float min (float a, float b)
- public static float parse (string str)
- public static bool try_parse (string str, out float result = null, out unowned string unparsed = null)
Methods:
- public float abs ()
- public float clamp (float low, float high)
- public bool is_finite ()
Determines if the given floating point number has finite value i.e. it is
normal, subnormal or zero, but not infinite or NAN.
- public int is_infinity ()
Determines if the given floating point number is a negative or positive
infinity
- public bool is_nan ()
Determines if the given floating point number is not-a-number (NaN).
- public bool is_normal ()
Determines if the given floating point number is normal, i.e. is neither
zero, subnormal, infinite, nor NaN.
- public string to_string (string format = "%g")
Similar to the standard C `sprintf()` function but safer, since it
calculates the maximum space required and allocates memory to hold the result.