To add pure fixed-point math functions (issue #1543), I found it would be better add some math constants (issue #1544). So here is a WIP PR which adds first two important constants, E and PI. The solution is as follows.
(1) In "fixed_point.h", I add two staic functions which return E and PI, respectively, referrng to the implementation of the fpm library.
(2) The from_fixedpoint() function is fixed to avoid the situation of narrowing warning/error furing compilation when the fractional_bits of created FixedPoint constant object is smaller than the predefined one, i.e., 61.
(3) By the way, I also amend the comment doc of safeshift function.
(4) In "fixed_point_test.cpp", I add some tests which utilizes the constants defined in "math_constant.h" for comparison. I also test constant under different precisions (see TestTypeShort in the tests).
To add pure fixed-point math functions (issue #1543), I found it would be better add some math constants (issue #1544). So here is a WIP PR which adds first two important constants, E and PI. The solution is as follows.
(1) In "fixed_point.h", I add two staic functions which return E and PI, respectively, referrng to the implementation of the fpm library.
(2) The from_fixedpoint() function is fixed to avoid the situation of narrowing warning/error furing compilation when the fractional_bits of created FixedPoint constant object is smaller than the predefined one, i.e., 61.
(3) By the way, I also amend the comment doc of safeshift function.
(4) In "fixed_point_test.cpp", I add some tests which utilizes the constants defined in "math_constant.h" for comparison. I also test constant under different precisions (see TestTypeShort in the tests).