aversive_10-03-12/modules/base/math/fixed_point/f16.h File Reference

#include <aversive.h>

Go to the source code of this file.

Data Structures

struct  fixed_16

Defines

#define f16_decimal   u.s.decimal
#define f16_integer   u.s.integer
#define F16_ZERO
#define F16_NAN
#define F16_IS_GT(x, y)   (f16_to_s16(x) > f16_to_s16(y))
#define F16_IS_LT(x, y)   (f16_to_s16(x) < f16_to_s16(y))
#define F16_IS_GE(x, y)   (f16_to_s16(x) >= f16_to_s16(y))
#define F16_IS_LE(x, y)   (f16_to_s16(x) <= f16_to_s16(y))
#define F16_IS_EQ(x, y)   (f16_to_s16(x) == f16_to_s16(y))
#define F16_IS_NE(x, y)   (f16_to_s16(x) != f16_to_s16(y))
#define F16_IS_NEG(x)   ((x).f16_integer < 0)
#define F16_IS_ZERO(x)   ((x).f16_integer == 0 && (x).f16_decimal == 0)

Typedefs

typedef struct fixed_16 f16

Functions

f16 f16_from_double (double f)
double f16_to_double (f16 fix)
f16 f16_from_integer (int8_t i, uint8_t d)
f16 f16_from_msb (int8_t i)
f16 f16_from_lsb (int8_t i)
f16 f16_neg (f16 f)
f16 f16_add (f16 a, f16 b)
f16 f16_sub (f16 a, f16 b)
f16 f16_inv (f16 f)
f16 f16_mul (f16 a, f16 b)
f16 f16_mul_msb (f16 a, f16 b)
f16 f16_div (f16 a, f16 b)
f16 f16_sqrt (f16 f)
void f16_print (f16 fix)


Define Documentation

#define f16_decimal   u.s.decimal

Definition at line 52 of file f16.h.

#define f16_integer   u.s.integer

Definition at line 53 of file f16.h.

#define F16_IS_EQ ( x,
 )     (f16_to_s16(x) == f16_to_s16(y))

Definition at line 73 of file f16.h.

Referenced by f16_print().

#define F16_IS_GE ( x,
 )     (f16_to_s16(x) >= f16_to_s16(y))

Definition at line 71 of file f16.h.

#define F16_IS_GT ( x,
 )     (f16_to_s16(x) > f16_to_s16(y))

Definition at line 69 of file f16.h.

#define F16_IS_LE ( x,
 )     (f16_to_s16(x) <= f16_to_s16(y))

Definition at line 72 of file f16.h.

#define F16_IS_LT ( x,
 )     (f16_to_s16(x) < f16_to_s16(y))

Definition at line 70 of file f16.h.

#define F16_IS_NE ( x,
 )     (f16_to_s16(x) != f16_to_s16(y))

Definition at line 74 of file f16.h.

#define F16_IS_NEG (  )     ((x).f16_integer < 0)

Definition at line 75 of file f16.h.

Referenced by f16_sqrt().

#define F16_IS_ZERO (  )     ((x).f16_integer == 0 && (x).f16_decimal == 0)

Definition at line 76 of file f16.h.

Referenced by f16_div(), and f16_inv().

#define F16_NAN

Value:

(              \
{                              \
    f16 __f;                   \
    __f.u.s16 = 0xFFFF;        \
    __f;                       \
})

Definition at line 62 of file f16.h.

Referenced by f16_div(), f16_inv(), f16_print(), and f16_sqrt().

#define F16_ZERO

Value:

(    \
{                     \
    f16 __f;          \
    __f.u.s16 = 0;    \
    __f;              \
})

Definition at line 55 of file f16.h.


Typedef Documentation

typedef struct fixed_16 f16


Function Documentation

f16 f16_add ( f16  a,
f16  b 
)

add a with b (=a+b)

Definition at line 28 of file f16_add.c.

f16 f16_div ( f16  a,
f16  b 
)

div a with b (=a/b)

Definition at line 26 of file f16_div.c.

References f16_inv(), F16_IS_ZERO, f16_mul(), and F16_NAN.

f16 f16_from_double ( double  f  ) 

convert a double to a f16

Definition at line 31 of file f16_double.c.

References parse_symbols::f, and POW2_8F.

f16 f16_from_integer ( int8_t  i,
uint8_t  d 
)

convert 2 integer (int8_t and uint8_t) to a f16

Definition at line 28 of file f16_int.c.

References parse_symbols::f.

f16 f16_from_lsb ( int8_t  i  ) 

convert lsb integer (int8_t) to a f16 ( -0.5 < ret < 0.5 )

Definition at line 51 of file f16_int.c.

References parse_symbols::f.

f16 f16_from_msb ( int8_t  i  ) 

convert msb integer (int8_t) to a f16

Definition at line 39 of file f16_int.c.

References parse_symbols::f.

f16 f16_inv ( f16  f  ) 

return opposite of the number (=1/f)

Definition at line 28 of file f16_inv.c.

References F16_IS_ZERO, and F16_NAN.

Referenced by f16_div().

f16 f16_mul ( f16  a,
f16  b 
)

mul a with b (=a*b)

Definition at line 27 of file f16_mul.c.

Referenced by f16_div(), and f16_sqrt().

f16 f16_mul_msb ( f16  a,
f16  b 
)

mul a with b (=a*b), but return only the msb

f16 f16_neg ( f16  f  ) 

return opposite of the number (=-f)

Definition at line 27 of file f16_neg.c.

void f16_print ( f16  fix  ) 

function that display a f16 to the standard output

Definition at line 26 of file f16_print.c.

References F16_IS_EQ, F16_NAN, and f16_to_double().

f16 f16_sqrt ( f16  f  ) 

sqrt of f

Definition at line 47 of file f16_sqrt.c.

References a, F16_IS_NEG, f16_mul(), and F16_NAN.

f16 f16_sub ( f16  a,
f16  b 
)

add a with b (=a-b)

Definition at line 28 of file f16_sub.c.

double f16_to_double ( f16  fix  ) 

convert a f16 to a double

Definition at line 40 of file f16_double.c.

References POW2_8F.

Referenced by f16_print().


Generated on Fri Mar 12 06:32:05 2010 for AVR by  doxygen 1.5.6