Skip to content
Snippets Groups Projects
Commit d78feb3d authored by baewoojin's avatar baewoojin
Browse files

Update README.md

parent 5d9b1aa7
No related branches found
No related tags found
No related merge requests found
...@@ -30,3 +30,33 @@ ...@@ -30,3 +30,33 @@
~~~ ~~~
- to add two fixed point numbers there is no need to conversion of data type - to add two fixed point numbers there is no need to conversion of data type
- just add two fixed point numbers and return result - just add two fixed point numbers and return result
- b. sub
~~~
#define fx_sub(a, b) ((a)-(b))
~~~
- to sub one fixed point number from another fixed point number there is no need to conversion of data type.
- just operate function without conversion of data type and return result
- c. mul
~~~
#define fx_mul(a, b) double_to_fx(fx_to_double (a) * fx_to_double (b))
~~~
- to mul two fixed pouint number shoul do type conversion
- first convert two fixed point number to double type and do mul operation
- second result calculated from first step should be converted to fixed point number(type conversion)
- d. div
~~~
#define fx_div(a, b) double_to_fx(fx_to_double (a) / fx_to_double (b))
~~~
- to div two fixed pouint number shoul do type conversion
- first convert two fixed point number to double type and do div operation
- second result calculated from first step should be converted to fixed point number(type conversion)
- e. fixed -> double
~~~
#define fx_to_double(a) (a/P2_2to32)
~~~
- to convert fixed point to double should divide fixed point number by 2^32(s31(32)=>decimal part bits)
- f. double -> fixed
~~~
#define double_to_fx(a) (long long)(a*P2_2to32)
~~~
- to convert double to fixed point should multiply double number and 2^32(s31(32)=>decimal part bits)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment