## GimpMath

GimpMath — Mathematical definitions and macros.

## Synopsis

    #define             RINT                                (x)
    #define             ROUND                               (x)
    #define             SQR                                 (x)
    #define             MAX255                              (a)
    #define             CLAMP0255                           (a)
    #define             gimp_deg_to_rad                     (angle)
    #define             gimp_rad_to_deg                     (angle)

## Description

Mathematical definitions and macros. These macros should be used rather than the ones from math.h for enhanced portability.

## Details

### RINT()

    #define             RINT(x)

This macro rounds its argument `x` to an integer value in floating point format.

`x` : | the value to be rounded.

### ROUND()

    #define ROUND(x) ((int) ((x) + 0.5))

This macro rounds its argument `x` to the nearest integer.

`x` : | the value to be rounded.

### SQR()

    #define SQR(x) ((x) * (x))

This macro squares its argument `x`.

`x` : | the value to be squared.

### MAX255()

    #define MAX255(a)  ((a) | (((a) & 256) - (((a) & 256) >> 8)))

This macro limits it argument `a`, an (0-511) int, to 255.

`a` : | the value to be limited.

### CLAMP0255()

    #define CLAMP0255(a)  CLAMP(a,0,255)

This macro clamps its argument `a`, an int32-range int, between 0 and 255 inclusive.

`a` : | the value to be clamped.

### gimp_deg_to_rad()

    #define gimp_deg_to_rad(angle) ((angle) * (2.0 * G_PI) / 360.0)

This macro converts its argument `angle` from degree to radian.

`angle` : | the angle to be converted.

### gimp_rad_to_deg()

    #define gimp_rad_to_deg(angle) ((angle) * 360.0 / (2.0 * G_PI))

This macro converts its argument `angle` from radian to degree.

`angle` : | the angle to be converted.