Q15 Library
mikroC PRO for dsPIC30/33 and PIC24 includes a library for operating and working with Q15 fractional number format.
Library Routines
- Q15_Abs
- Q15_Add
- Q15_Sub
- Q15_Itof
- Q15_Ftoi
- Q15_Itoa
- Q15_Atoi
- Q15_Sin
- Q15_Cos
- Q15_Tan
- Q15_Asin
- Q15_Acos
- Q15_Atan
- Q15_Log
Q15_Abs
Prototype |
int Q15_Abs (int x); |
---|---|
Description |
Function calculates absolute value of the Q15 fractional format number. |
Parameters |
|
Returns |
Function returns number in Q15 fractional format, ranging from 0 to 32767. |
Q15_Add
Prototype |
char Q15_Add(int x, int y, int *z); |
---|---|
Description |
Function sums two Q15 format numbers. If the result exceeds [-32768, 32767] limits, result will be maximal(minimal) number in Q15 format. |
Parameters |
|
Returns |
|
Q15_Sub
Prototype |
int Q15_Sub(int x, int y, int *z); |
---|---|
Description |
Function subtracts two Q15 format numbers. If the result exceeds [-32768, 32767] limits, result will be maximal(minimal) number in Q15 format. |
Parameters |
|
Returns |
|
Q15_Itof
Prototype |
float Q15_Itof(int x); |
---|---|
Description |
Function converts number from the Q15 fractional number format to floating point number format. |
Parameters |
|
Returns |
Function returns number in single precision floating point format, ranging from -1 to 0.99997. |
Q15_Ftoi
Prototype |
int Q15_Ftoi(float x); |
---|---|
Description |
Function converts number from the single precision floating point number format to Q15 fractional number format. Input number scope should be in the range of [-1.00000, 0.99997]. If the floating point number is not in this range, the resulting number will be 0x7FFF (0x8000). |
Parameters |
|
Returns |
Converted Q15 fractional fromat number in the range of -32768 to 32767. |
Q15_Itoa
Prototype |
void Q15_Itoa(int x, char *s); |
---|---|
Description |
Function converts number from the Q15 fractional format to ASCII string. Output ASCII string is in the following format : sn.ddddddddddddddd
|
Parameters |
|
Returns |
Nothing. |
Q15_Atoi
Prototype |
char Q15_Atoi(char *s, int *out); |
---|---|
Description |
Function converts the input ASCII string s into a number in Q15 fractional point format. Input ASCII string should be in the following format: _s_n.ddddddddddddddd_
Parser of input characters has following features :
|
Parameters |
|
Returns |
|
Q15_Cos
Prototype |
int Q15_Cos(int x); |
---|---|
Description |
Function returns the cosine of |
Parameters |
|
Returns |
Function returns value in the Q15 format, ranging from 17705 to 32767. |
Q15_Sin
Prototype |
int Q15_Sin(int x); |
---|---|
Description |
Function returns the sine of |
Parameters |
|
Returns |
Function returns value in the Q15 format, ranging from -27573 to 27573. |
Q15_Tan
Prototype |
int Q15_Tan(int x); |
---|---|
Description |
Function returns the tangent of |
Parameters |
|
Returns |
Function returns value in the Q15 format, ranging from -32768 to 32767. |
Q15_Asin
Prototype |
int Q15_Asin(int x); |
---|---|
Description |
Function returns the arc sine of |
Parameters |
|
Returns |
Function returns value in the Q15 format, ranging from -32768 to 32767. |
Q15_Atan
Prototype |
int Q15_Atan(int x); |
---|---|
Description |
Function returns the arc tangent of |
Parameters |
|
Returns |
Function returns value in the Q15 format, ranging from -25736 to 25735. |
Q15_Acos
Prototype |
int Q15_Acos(int x); |
---|---|
Description |
Function returns the arc cosine of |
Parameters |
|
Returns |
Function returns value in the Q15 format, ranging from 256 to 32767. |
Q15_Log
Prototype |
int Q15_Log(int x); |
---|---|
Description |
Function returns the logarithm of |
Parameters |
|
Returns |
Function returns value in the Q15 format, ranging from -32767 to 0. |
What do you think about this topic ? Send us feedback!