bgottula / fixed Goto Github PK
View Code? Open in Web Editor NEWClass definition for fixed point arithmetic in C++
License: MIT License
Class definition for fixed point arithmetic in C++
License: MIT License
The half-adder rounding method can produce outputs that exceed the intended output range. Example: 5-bit value 15 roundBy(2) will produce the value 4, which exceeds the range of a 3-bit 2's complement integer. This should probably be fixed by saturating the offending outputs to the new output range.
C++ lets you use the explicit keyword in some cases to avoid copying of classes when you don't want it. You may want to use this for FixedPoint
/ComplexFixedPoint
.
For example, let's say I create a Visual C++ project AmazingDSP that has fixed as a dependency, and AmazingDSP is version controlled with Git. Ideally, I would like to be able to clone AmazingDSP from the repository using Git and have fixed be pulled down from GitHub (perhaps from a particular tag or commit to avoid version conflicts) automatically. This avoids a manual procedure like "clone AmazingDSP, then cd into this directory, then clone fixed and checkout this particular tag." Besides being a burden on anyone who wants to use AmazingDSP project, this also complicates automated continuous integration using BuildBot which also needs to checkout and build the project from source.
Possible solutions:
References:
http://blogs.atlassian.com/2014/04/git-project-dependencies/
C++11 adds the ability for classes to implement user-defined literals. Hypothetically, with this feature, you could make it so that writing 1.234_fxp
anywhere in a code file will create a Fxp
literal with that value.
This may not work so well when you want multiple values (e.g. value and bit length, or real and imaginary part). Deserves some investigation.
Should make the performance penalty of strict checking optional.
Resizing functions (round, truncate, saturate, etc.) could work one of two ways:
These operators are already private and their intended behavior is not obvious. Only >> is used in truncateBy() where the functionality can be replaced.
Suggest setting width to an "invalid" value in the default constructor; on first assignment, this is set to the width of the rhs.
Compound operators += and *= resize the lhs object even when the width is immutable under assignment. This is inconsistent with the behavior of the regular assignment operator =, which throws an exception if the width of the rhs does not match the lhs.
There may be cases where it is desirable for operators like += to not result in a size change. For example, in an accumulator. However, this would require an implicit size reduction, which violates one of the principles of the project (no implicit resizing).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.