这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@AyiStar
Copy link
Contributor

@AyiStar AyiStar commented Dec 1, 2023

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).

@AyiStar AyiStar marked this pull request as draft December 2, 2023 00:57
@AyiStar AyiStar changed the title [WIP] try adding two math constants E and PI for FixedPoint Add math constants corresbonding to util/math_constant.h for FixedPoint Dec 4, 2023
@AyiStar AyiStar changed the title Add math constants corresbonding to util/math_constant.h for FixedPoint Add math constants corresbonding to util/math_constants.h for FixedPoint Dec 4, 2023
@AyiStar AyiStar marked this pull request as ready for review December 4, 2023 09:17
@AyiStar
Copy link
Contributor Author

AyiStar commented Dec 4, 2023

Have added a full set of math constants for FixedPoint.

Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty nice, thank you!

@heinezen heinezen linked an issue Dec 4, 2023 that may be closed by this pull request
1 task
@heinezen heinezen added nice new thing ☺ A new feature that was not there before lang: c++ Done in C++ code labels Dec 4, 2023
@heinezen heinezen merged commit 3c3de39 into SFTtech:master Dec 4, 2023
@AyiStar AyiStar deleted the add-math-const branch December 5, 2023 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang: c++ Done in C++ code nice new thing ☺ A new feature that was not there before

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fixed point math constants

2 participants