yarf 0.1
Yet Another RepRap Firmware
Defines | Functions
src/util/math.h File Reference

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:
minthe minimum value
xthe value to bound
maxthe 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:
athe first number
bthe 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:
athe first number
bthe 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:
xthe 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:
xthe 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:
xthe 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:
xthe number of which to return the square
Returns:
x * x

Definition at line 106 of file math.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines