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


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




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




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




Definition at line 73 of file f32.h.

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




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




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




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




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




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




Definition at line 75 of file f32.h.

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




Definition at line 76 of file f32.h.

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


\textbf{Value:}

\begin{Code}\begin{verbatim}(              \
{                              \
    f32 __f;                   \
    __f.u.s32 = 0xFFFFFFFF;    \
    __f;                       \
})
\end{verbatim}
\end{Code}


Definition at line 62 of file f32.h.

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


\textbf{Value:}

\begin{Code}\begin{verbatim}(    \
{                     \
    f32 __f;          \
    __f.u.s32 = 0;    \
    __f;              \
})
\end{verbatim}
\end{Code}


Definition at line 55 of file f32.h.

Referenced by f32\_\-sqrt().

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




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


add a with b (=a+b) 

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


div a with b (=a/b) 

Definition at line 25 of file f32\_\-div.c.

References f32\_\-inv(), F32\_\-IS\_\-ZERO, f32\_\-mul(), and F32\_\-NAN.\index{f32.h@{f32.h}!f32\_\-from\_\-double@{f32\_\-from\_\-double}}
\index{f32\_\-from\_\-double@{f32\_\-from\_\-double}!f32.h@{f32.h}}
\subsubsection[f32\_\-from\_\-double]{\setlength{\rightskip}{0pt plus 5cm}{\bf f32} f32\_\-from\_\-double (double {\em f})}\label{f32_8h_515d4161cb4d799a555a02b97ea7b97b}


convert a double to a f32 

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

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


convert 2 integer (int16\_\-t and uint16\_\-t) to a f32 

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

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


convert lsb integer (int16\_\-t) to a f32 ( -0.5 $<$ ret $<$ 0.5 ) 

Definition at line 51 of file f32\_\-int.c.

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


convert msb integer (int16\_\-t) to a f32 

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

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


return opposite of the number (=1/f) 

Definition at line 28 of file f32\_\-inv.c.

References F32\_\-IS\_\-ZERO, and F32\_\-NAN.

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


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

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

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


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


return opposite of the number (=-f) 

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


function that display a f32 to the standard output 

Definition at line 27 of file f32\_\-print.c.

References F32\_\-IS\_\-EQ, F32\_\-NAN, and f32\_\-to\_\-double().\index{f32.h@{f32.h}!f32\_\-sqrt@{f32\_\-sqrt}}
\index{f32\_\-sqrt@{f32\_\-sqrt}!f32.h@{f32.h}}
\subsubsection[f32\_\-sqrt]{\setlength{\rightskip}{0pt plus 5cm}{\bf f32} f32\_\-sqrt ({\bf f32} {\em f})}\label{f32_8h_54b66824a7f23c38ff9d631f8035cbd0}


sqrt of f 

Definition at line 46 of file f32\_\-sqrt.c.

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


add a with b (=a-b) 

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


convert a f32 to a double 

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

References POW2\_\-16F.

Referenced by f32\_\-print().