Complements the <math.h> header file with some basic math functions and macros.
More...
#include <math.h>
#include <stdint.h>
Go to the source code of this file.
Defines |
#define | MIN(a, b) ((a)<(b)?(a):(b)) |
| Returns the smallest of two numbers.
|
#define | MAX(a, b) ((a)>(b)?(a):(b)) |
| Returns the largest of two numbers.
|
#define | SIGNUM(x) (((x) < 0)?(-1):(1)) |
| Returns the sign of a number.
|
#define | BOUNDS(min, x, max) MAX(min,MIN(x,max)) |
| Bounds a given value to a given minimum and maximum value.
|
Functions |
float | fsquare (float x) |
| Returns the square of a floating point number.
|
unsigned long | lsquare (long x) |
| Returns the square of a long integer, if it fits within the representable range of unsigned long integers.
|
uint32_t | uint16_square (uint16_t x) |
| Returns the square of an unsigned 16-bit integer.
|
Detailed Description
Complements the <math.h> header file with some basic math functions and macros.
- Author:
- Pieter Agten (pieter.agten@gmail.com)
- Date:
- 2 nov 2011
Definition in file math.h.
Define Documentation
#define BOUNDS |
( |
|
min, |
|
|
|
x, |
|
|
|
max |
|
) |
| MAX(min,MIN(x,max)) |
Bounds a given value to a given minimum and maximum value.
- Parameters:
-
min | the minimum value |
x | the value to bound |
max | the maximum value |
- Returns:
- min if x < min, or max if x > max, or x otherwise
Definition at line 70 of file math.h.
#define MAX |
( |
|
a, |
|
|
|
b |
|
) |
| ((a)>(b)?(a):(b)) |
Returns the largest of two numbers.
- Parameters:
-
a | the first number |
b | the second number |
- Returns:
- a if a > b and b otherwise
Definition at line 52 of file math.h.
#define MIN |
( |
|
a, |
|
|
|
b |
|
) |
| ((a)<(b)?(a):(b)) |
Returns the smallest of two numbers.
- Parameters:
-
a | the first number |
b | the second number |
- Returns:
- a if a < b and b otherwise
Definition at line 43 of file math.h.
#define SIGNUM |
( |
|
x | ) |
(((x) < 0)?(-1):(1)) |
Returns the sign of a number.
- Parameters:
-
x | the number of which to return the sign |
- Returns:
- 1 if x >= 0 and -1 otherwise
Definition at line 60 of file math.h.
Function Documentation
float fsquare |
( |
float |
x | ) |
[inline] |
Returns the square of a floating point number.
- Parameters:
-
x | the number of which to return the square |
- Returns:
- x * x
Definition at line 80 of file math.h.
unsigned long lsquare |
( |
long |
x | ) |
[inline] |
Returns the square of a long integer, if it fits within the representable range of unsigned long integers.
- Parameters:
-
x | the number of which to return the square |
- Returns:
- x * x, if that fits within the representable range of unsigned long integers, or an undefined value otherwise
Definition at line 94 of file math.h.
uint32_t uint16_square |
( |
uint16_t |
x | ) |
[inline] |
Returns the square of an unsigned 16-bit integer.
- Parameters:
-
x | the number of which to return the square |
- Returns:
- x * x
Definition at line 106 of file math.h.