\section{aversive\_\-10-03-12/modules/base/math/fixed\_\-point/f16.h File Reference}
\label{f16_8h}\index{aversive\_\-10-03-12/modules/base/math/fixed\_\-point/f16.h@{aversive\_\-10-03-12/modules/base/math/fixed\_\-point/f16.h}}
{\tt \#include $<$aversive.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf fixed\_\-16}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf f16\_\-decimal}~u.s.decimal
\item 
\#define {\bf f16\_\-integer}~u.s.integer
\item 
\#define {\bf F16\_\-ZERO}
\item 
\#define {\bf F16\_\-NAN}
\item 
\#define {\bf F16\_\-IS\_\-GT}(x, y)~(f16\_\-to\_\-s16(x) $>$  f16\_\-to\_\-s16(y))
\item 
\#define {\bf F16\_\-IS\_\-LT}(x, y)~(f16\_\-to\_\-s16(x) $<$  f16\_\-to\_\-s16(y))
\item 
\#define {\bf F16\_\-IS\_\-GE}(x, y)~(f16\_\-to\_\-s16(x) $>$= f16\_\-to\_\-s16(y))
\item 
\#define {\bf F16\_\-IS\_\-LE}(x, y)~(f16\_\-to\_\-s16(x) $<$= f16\_\-to\_\-s16(y))
\item 
\#define {\bf F16\_\-IS\_\-EQ}(x, y)~(f16\_\-to\_\-s16(x) == f16\_\-to\_\-s16(y))
\item 
\#define {\bf F16\_\-IS\_\-NE}(x, y)~(f16\_\-to\_\-s16(x) != f16\_\-to\_\-s16(y))
\item 
\#define {\bf F16\_\-IS\_\-NEG}(x)~((x).f16\_\-integer $<$ 0)
\item 
\#define {\bf F16\_\-IS\_\-ZERO}(x)~((x).f16\_\-integer == 0 \&\& (x).f16\_\-decimal == 0)
\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef struct {\bf fixed\_\-16} {\bf f16}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
{\bf f16} {\bf f16\_\-from\_\-double} (double f)
\item 
double {\bf f16\_\-to\_\-double} ({\bf f16} fix)
\item 
{\bf f16} {\bf f16\_\-from\_\-integer} (int8\_\-t {\bf i}, uint8\_\-t d)
\item 
{\bf f16} {\bf f16\_\-from\_\-msb} (int8\_\-t {\bf i})
\item 
{\bf f16} {\bf f16\_\-from\_\-lsb} (int8\_\-t {\bf i})
\item 
{\bf f16} {\bf f16\_\-neg} ({\bf f16} f)
\item 
{\bf f16} {\bf f16\_\-add} ({\bf f16} {\bf a}, {\bf f16} b)
\item 
{\bf f16} {\bf f16\_\-sub} ({\bf f16} {\bf a}, {\bf f16} b)
\item 
{\bf f16} {\bf f16\_\-inv} ({\bf f16} f)
\item 
{\bf f16} {\bf f16\_\-mul} ({\bf f16} {\bf a}, {\bf f16} b)
\item 
{\bf f16} {\bf f16\_\-mul\_\-msb} ({\bf f16} {\bf a}, {\bf f16} b)
\item 
{\bf f16} {\bf f16\_\-div} ({\bf f16} {\bf a}, {\bf f16} b)
\item 
{\bf f16} {\bf f16\_\-sqrt} ({\bf f16} f)
\item 
void {\bf f16\_\-print} ({\bf f16} fix)
\end{CompactItemize}


\subsection{Define Documentation}
\index{f16.h@{f16.h}!f16\_\-decimal@{f16\_\-decimal}}
\index{f16\_\-decimal@{f16\_\-decimal}!f16.h@{f16.h}}
\subsubsection[f16\_\-decimal]{\setlength{\rightskip}{0pt plus 5cm}\#define f16\_\-decimal~u.s.decimal}\label{f16_8h_f65f99229375d35e444a52fa67be12e9}




Definition at line 52 of file f16.h.\index{f16.h@{f16.h}!f16\_\-integer@{f16\_\-integer}}
\index{f16\_\-integer@{f16\_\-integer}!f16.h@{f16.h}}
\subsubsection[f16\_\-integer]{\setlength{\rightskip}{0pt plus 5cm}\#define f16\_\-integer~u.s.integer}\label{f16_8h_870a6511f128376beaaaff5a2c55b3e1}




Definition at line 53 of file f16.h.\index{f16.h@{f16.h}!F16\_\-IS\_\-EQ@{F16\_\-IS\_\-EQ}}
\index{F16\_\-IS\_\-EQ@{F16\_\-IS\_\-EQ}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-EQ]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-EQ(x, \/  y)~(f16\_\-to\_\-s16(x) == f16\_\-to\_\-s16(y))}\label{f16_8h_b23e75104826e1fe8a528842241e551f}




Definition at line 73 of file f16.h.

Referenced by f16\_\-print().\index{f16.h@{f16.h}!F16\_\-IS\_\-GE@{F16\_\-IS\_\-GE}}
\index{F16\_\-IS\_\-GE@{F16\_\-IS\_\-GE}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-GE]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-GE(x, \/  y)~(f16\_\-to\_\-s16(x) $>$= f16\_\-to\_\-s16(y))}\label{f16_8h_89db88cacb01f0d2fc44fd0190755dbd}




Definition at line 71 of file f16.h.\index{f16.h@{f16.h}!F16\_\-IS\_\-GT@{F16\_\-IS\_\-GT}}
\index{F16\_\-IS\_\-GT@{F16\_\-IS\_\-GT}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-GT]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-GT(x, \/  y)~(f16\_\-to\_\-s16(x) $>$  f16\_\-to\_\-s16(y))}\label{f16_8h_e761b2b650a8662069a814563922a749}




Definition at line 69 of file f16.h.\index{f16.h@{f16.h}!F16\_\-IS\_\-LE@{F16\_\-IS\_\-LE}}
\index{F16\_\-IS\_\-LE@{F16\_\-IS\_\-LE}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-LE]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-LE(x, \/  y)~(f16\_\-to\_\-s16(x) $<$= f16\_\-to\_\-s16(y))}\label{f16_8h_c12b61e179f1a77071f46b4ba76792ed}




Definition at line 72 of file f16.h.\index{f16.h@{f16.h}!F16\_\-IS\_\-LT@{F16\_\-IS\_\-LT}}
\index{F16\_\-IS\_\-LT@{F16\_\-IS\_\-LT}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-LT]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-LT(x, \/  y)~(f16\_\-to\_\-s16(x) $<$  f16\_\-to\_\-s16(y))}\label{f16_8h_a7fc6aa9274f6ee558e07a47ee0faf1f}




Definition at line 70 of file f16.h.\index{f16.h@{f16.h}!F16\_\-IS\_\-NE@{F16\_\-IS\_\-NE}}
\index{F16\_\-IS\_\-NE@{F16\_\-IS\_\-NE}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-NE]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-NE(x, \/  y)~(f16\_\-to\_\-s16(x) != f16\_\-to\_\-s16(y))}\label{f16_8h_80858287a90cbfab4a8fd3f722ac04a7}




Definition at line 74 of file f16.h.\index{f16.h@{f16.h}!F16\_\-IS\_\-NEG@{F16\_\-IS\_\-NEG}}
\index{F16\_\-IS\_\-NEG@{F16\_\-IS\_\-NEG}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-NEG]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-NEG(x)~((x).f16\_\-integer $<$ 0)}\label{f16_8h_0255d9fa2b806f83dea4f33c589a09fc}




Definition at line 75 of file f16.h.

Referenced by f16\_\-sqrt().\index{f16.h@{f16.h}!F16\_\-IS\_\-ZERO@{F16\_\-IS\_\-ZERO}}
\index{F16\_\-IS\_\-ZERO@{F16\_\-IS\_\-ZERO}!f16.h@{f16.h}}
\subsubsection[F16\_\-IS\_\-ZERO]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-IS\_\-ZERO(x)~((x).f16\_\-integer == 0 \&\& (x).f16\_\-decimal == 0)}\label{f16_8h_f7d9eef89a778877a005fcb0eda1fec3}




Definition at line 76 of file f16.h.

Referenced by f16\_\-div(), and f16\_\-inv().\index{f16.h@{f16.h}!F16\_\-NAN@{F16\_\-NAN}}
\index{F16\_\-NAN@{F16\_\-NAN}!f16.h@{f16.h}}
\subsubsection[F16\_\-NAN]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-NAN}\label{f16_8h_4d4946a74bc6b7381def67fc29875a37}


\textbf{Value:}

\begin{Code}\begin{verbatim}(              \
{                              \
    f16 __f;                   \
    __f.u.s16 = 0xFFFF;        \
    __f;                       \
})
\end{verbatim}
\end{Code}


Definition at line 62 of file f16.h.

Referenced by f16\_\-div(), f16\_\-inv(), f16\_\-print(), and f16\_\-sqrt().\index{f16.h@{f16.h}!F16\_\-ZERO@{F16\_\-ZERO}}
\index{F16\_\-ZERO@{F16\_\-ZERO}!f16.h@{f16.h}}
\subsubsection[F16\_\-ZERO]{\setlength{\rightskip}{0pt plus 5cm}\#define F16\_\-ZERO}\label{f16_8h_f84e5f5bd2802f391860414a5c6bfac8}


\textbf{Value:}

\begin{Code}\begin{verbatim}(    \
{                     \
    f16 __f;          \
    __f.u.s16 = 0;    \
    __f;              \
})
\end{verbatim}
\end{Code}


Definition at line 55 of file f16.h.

\subsection{Typedef Documentation}
\index{f16.h@{f16.h}!f16@{f16}}
\index{f16@{f16}!f16.h@{f16.h}}
\subsubsection[f16]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf fixed\_\-16}  {\bf f16}}\label{f16_8h_30fee74b868a45d65223a2c4ff34d7b3}




\subsection{Function Documentation}
\index{f16.h@{f16.h}!f16\_\-add@{f16\_\-add}}
\index{f16\_\-add@{f16\_\-add}!f16.h@{f16.h}}
\subsubsection[f16\_\-add]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-add ({\bf f16} {\em a}, \/  {\bf f16} {\em b})}\label{f16_8h_6fc6eb9467176c8d14cb4e93b5f767b3}


add a with b (=a+b) 

Definition at line 28 of file f16\_\-add.c.\index{f16.h@{f16.h}!f16\_\-div@{f16\_\-div}}
\index{f16\_\-div@{f16\_\-div}!f16.h@{f16.h}}
\subsubsection[f16\_\-div]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-div ({\bf f16} {\em a}, \/  {\bf f16} {\em b})}\label{f16_8h_9b2ea7ab924790803a9b2aca621f61ff}


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.\index{f16.h@{f16.h}!f16\_\-from\_\-double@{f16\_\-from\_\-double}}
\index{f16\_\-from\_\-double@{f16\_\-from\_\-double}!f16.h@{f16.h}}
\subsubsection[f16\_\-from\_\-double]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-from\_\-double (double {\em f})}\label{f16_8h_9d3003e231ef1a34979526db5a30d375}


convert a double to a f16 

Definition at line 31 of file f16\_\-double.c.

References parse\_\-symbols::f, and POW2\_\-8F.\index{f16.h@{f16.h}!f16\_\-from\_\-integer@{f16\_\-from\_\-integer}}
\index{f16\_\-from\_\-integer@{f16\_\-from\_\-integer}!f16.h@{f16.h}}
\subsubsection[f16\_\-from\_\-integer]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-from\_\-integer (int8\_\-t {\em i}, \/  uint8\_\-t {\em d})}\label{f16_8h_8f35f9e6df6f038beff84a0225489a26}


convert 2 integer (int8\_\-t and uint8\_\-t) to a f16 

Definition at line 28 of file f16\_\-int.c.

References parse\_\-symbols::f.\index{f16.h@{f16.h}!f16\_\-from\_\-lsb@{f16\_\-from\_\-lsb}}
\index{f16\_\-from\_\-lsb@{f16\_\-from\_\-lsb}!f16.h@{f16.h}}
\subsubsection[f16\_\-from\_\-lsb]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-from\_\-lsb (int8\_\-t {\em i})}\label{f16_8h_018da81437537977fbced6e7aeea8e0b}


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.\index{f16.h@{f16.h}!f16\_\-from\_\-msb@{f16\_\-from\_\-msb}}
\index{f16\_\-from\_\-msb@{f16\_\-from\_\-msb}!f16.h@{f16.h}}
\subsubsection[f16\_\-from\_\-msb]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-from\_\-msb (int8\_\-t {\em i})}\label{f16_8h_9dc6a271339061bbcdbe209bddc98e6d}


convert msb integer (int8\_\-t) to a f16 

Definition at line 39 of file f16\_\-int.c.

References parse\_\-symbols::f.\index{f16.h@{f16.h}!f16\_\-inv@{f16\_\-inv}}
\index{f16\_\-inv@{f16\_\-inv}!f16.h@{f16.h}}
\subsubsection[f16\_\-inv]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-inv ({\bf f16} {\em f})}\label{f16_8h_1ef5310df2f417aeaaaf6d4728ee9f54}


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().\index{f16.h@{f16.h}!f16\_\-mul@{f16\_\-mul}}
\index{f16\_\-mul@{f16\_\-mul}!f16.h@{f16.h}}
\subsubsection[f16\_\-mul]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-mul ({\bf f16} {\em a}, \/  {\bf f16} {\em b})}\label{f16_8h_84ba83b66ded105b08603987fd058b92}


mul a with b (=a$\ast$b) 

Definition at line 27 of file f16\_\-mul.c.

Referenced by f16\_\-div(), and f16\_\-sqrt().\index{f16.h@{f16.h}!f16\_\-mul\_\-msb@{f16\_\-mul\_\-msb}}
\index{f16\_\-mul\_\-msb@{f16\_\-mul\_\-msb}!f16.h@{f16.h}}
\subsubsection[f16\_\-mul\_\-msb]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-mul\_\-msb ({\bf f16} {\em a}, \/  {\bf f16} {\em b})}\label{f16_8h_0352ea34f4f98d96dffba4a801c9d621}


mul a with b (=a$\ast$b), but return only the msb \index{f16.h@{f16.h}!f16\_\-neg@{f16\_\-neg}}
\index{f16\_\-neg@{f16\_\-neg}!f16.h@{f16.h}}
\subsubsection[f16\_\-neg]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-neg ({\bf f16} {\em f})}\label{f16_8h_8a5f0134d89c6da784884f84bb55a538}


return opposite of the number (=-f) 

Definition at line 27 of file f16\_\-neg.c.\index{f16.h@{f16.h}!f16\_\-print@{f16\_\-print}}
\index{f16\_\-print@{f16\_\-print}!f16.h@{f16.h}}
\subsubsection[f16\_\-print]{\setlength{\rightskip}{0pt plus 5cm}void f16\_\-print ({\bf f16} {\em fix})}\label{f16_8h_dd528e327e721f5cf3c7d11ad18b9067}


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().\index{f16.h@{f16.h}!f16\_\-sqrt@{f16\_\-sqrt}}
\index{f16\_\-sqrt@{f16\_\-sqrt}!f16.h@{f16.h}}
\subsubsection[f16\_\-sqrt]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-sqrt ({\bf f16} {\em f})}\label{f16_8h_be877d4a5d6efd70c8ae1039a393f2a4}


sqrt of f 

Definition at line 47 of file f16\_\-sqrt.c.

References a, F16\_\-IS\_\-NEG, f16\_\-mul(), and F16\_\-NAN.\index{f16.h@{f16.h}!f16\_\-sub@{f16\_\-sub}}
\index{f16\_\-sub@{f16\_\-sub}!f16.h@{f16.h}}
\subsubsection[f16\_\-sub]{\setlength{\rightskip}{0pt plus 5cm}{\bf f16} f16\_\-sub ({\bf f16} {\em a}, \/  {\bf f16} {\em b})}\label{f16_8h_2682198ed387438081771b5e93a6f7cd}


add a with b (=a-b) 

Definition at line 28 of file f16\_\-sub.c.\index{f16.h@{f16.h}!f16\_\-to\_\-double@{f16\_\-to\_\-double}}
\index{f16\_\-to\_\-double@{f16\_\-to\_\-double}!f16.h@{f16.h}}
\subsubsection[f16\_\-to\_\-double]{\setlength{\rightskip}{0pt plus 5cm}double f16\_\-to\_\-double ({\bf f16} {\em fix})}\label{f16_8h_997b87870902fa7370a61132cd7657cf}


convert a f16 to a double 

Definition at line 40 of file f16\_\-double.c.

References POW2\_\-8F.

Referenced by f16\_\-print().