Q31 Library
mikroBasic PRO for ARM includes a library for operating and working with Q31 fractional number format.
Library Routines
- Q31_Abs
- Q31_Add
- Q31_Sub
- Q31_Itof
- Q31_Ftoi
- Q31_Itoa
- Q31_Atoi
- Q31_Sin
- Q31_Cos
- Q31_Tan
- Q31_Asin
- Q31_Acos
- Q31_Atan
- Q31_Log
Q31_Abs
Prototype |
sub function Q31_Abs(dim input as longint) as longint |
---|---|
Description |
Function calculates absolute value of the Q31 fractional format number. |
Parameters |
|
Returns |
Function returns Q31 output number. |
Q31_Add
Prototype |
sub function Q31_Add(dim x as longint, dim y as longint, dim byref z as longint) as byte |
---|---|
Description |
Function sums two Q31 format numbers. If the result exceeds [-2147483648, 2147483647] limits, result will be maximal(minimal) number in Q31 format. |
Parameters |
|
Returns |
|
Q31_Sub
Prototype |
sub function Q31_Sub(dim x as longint, dim y as longint, dim byref z as longint) as byte |
---|---|
Description |
Function subtracts two Q31 format numbers. If the result exceeds [-2147483648, 2147483647] limits, result will be maximal(minimal) number in Q31 format. |
Parameters |
|
Returns |
|
Q31_Itof
Prototype |
sub function Q31_Itof(dim x as longint) as real |
---|---|
Description |
Function converts number from the Q31 fractional number format to floating point number format. |
Parameters |
|
Returns |
Function returns resulting floating point number. |
Q31_Ftoi
Prototype |
sub function Q31_Ftoi(dim f as real) as longint |
---|---|
Description |
Function converts number from the floating point number format to Q31 fractional number format. Input number scope should be in the range of [-1.00000, 0.99996]. If the floating point number is not in this range, the resulting number will be 0x7FFFFFFF (0x80000000). |
Parameters |
|
Returns |
Function returns resulting Q31 fractional format number. |
Q31_Itoa
Prototype |
sub procedure Q31_Itoa(dim x as longint, dim byref s as string) |
---|---|
Description |
Function converts number from the Q31 fractional format to ASCII string. Output ASCII string is in the following format : sn.ddddddddddddddddddddddddddddddd
|
Parameters |
|
Returns |
Nothing. |
Q31_Atoi
Prototype |
sub function Q31_Atoi(dim byref s as string, dim byref x as longint) as word |
---|---|
Description |
Function converts the input ASCII string s into a number in Q31 fractional point format. Input ASCII string should be in the following format: sn.ddddddddddddddddddddddddddddddd
|
Parameters |
|
Returns |
|
Q31_Cos
Prototype |
sub function Q31_Cos(dim x as longint) as longint |
---|---|
Description |
Function returns the cosine of |
Parameters |
|
Returns |
Function returns value in the Q31 format, ranging from 1160290361 to 2147483647. |
Q31_Sin
Prototype |
sub function Q31_Sin(dim x as longint) as longint |
---|---|
Description |
Function returns the sine of |
Parameters |
|
Returns |
Function returns value in the Q31 format, ranging from -1807039907 to 1807039904. |
Q31_Tan
Prototype |
sub function Q31_Tan(dim x as longint) as longint |
---|---|
Description |
Function returns the tangent of |
Parameters |
|
Returns |
Function returns value in the Q31 format, ranging from -2147483648 to 2147483647. |
Q31_Asin
Prototype |
sub function Q31_Asin(dim x as longint) as longint |
---|---|
Description |
Function returns the arc sine of |
Parameters |
|
Returns |
Function returns value in the Q31 format, ranging from -2147483648 to 2147483647. |
Q31_Atan
Prototype |
sub function Q31_Atan(dim x as longint) as longint |
---|---|
Description |
Function returns the arc tangent of |
Parameters |
|
Returns |
Function returns value in the Q31 format, ranging from -1673210000 do 1673209982. |
Q31_Acos
Prototype |
sub function Q31_Acos(dim x as longint) as longint |
---|---|
Description |
Function returns the arc cosine of |
Parameters |
|
Returns |
Function returns value in the Q31 format, ranging from 189407136 do 2147458881. |
Q31_Log
Prototype |
sub function Q31_Log(dim x as longint) as longint |
---|---|
Description |
Function returns the logarithm of |
Parameters |
|
Returns |
Function returns value in the Q31 format, ranging from -2144585218 to 0. |
What do you think about this topic ? Send us feedback!