Math utilities

Math utilities — Mathematical utilities

Synopsis

#include <ctpl/mathutils.h>

#define             CTPL_MATH_FLOAT_EQ                  (a,
                                                         b)
gboolean            ctpl_math_string_to_float           (const gchar *string,
                                                         gdouble *value);
gboolean            ctpl_math_string_to_int             (const gchar *string,
                                                         glong *value);
#define             ctpl_math_float_to_string           (f)
#define             ctpl_math_int_to_string             (i)

Description

Various math utility function and macros that are use by the implementation of CTPL.

Details

CTPL_MATH_FLOAT_EQ()

#define             CTPL_MATH_FLOAT_EQ(a, b)

Checks whether two floating-point values are equal.

a :

A floating-point value

b :

Another floating-point value

Returns :

TRUE if a and b are equal, FALSE otherwise.

ctpl_math_string_to_float ()

gboolean            ctpl_math_string_to_float           (const gchar *string,
                                                         gdouble *value);

Converts a whole string to a float.

string :

A string containing a number

value :

A pointer to fill with the result

Returns :

TRUE if the string was correctly converted, FALSE otherwise.

ctpl_math_string_to_int ()

gboolean            ctpl_math_string_to_int             (const gchar *string,
                                                         glong *value);

Converts a whole string to an integer.

string :

A string containing a number

value :

A pointer to fill with the result

Returns :

TRUE if the string was correctly converted, FALSE otherwise.

ctpl_math_float_to_string()

#define             ctpl_math_float_to_string(f)

Converts a floating-point number to a string.

f :

A floating-point number (C's double)

Returns :

A newly allocated string holding a representation of f in the C locale. This string should be free with g_free().

ctpl_math_int_to_string()

#define             ctpl_math_int_to_string(i)

Converts an integer number to a string.

i :

An integer number (C's long int)

Returns :

A newly allocated string holding a representation of i in the C locale. This string should be free with g_free().