Skip to content
bgottula edited this page Oct 17, 2014 · 2 revisions

The purpose of the FixedPoint and ComplexFixedPoint types is to extend the capabilities of built-in C++ types int64_t and std::complex<int64_t> to facilitate development of fixed-point algorithms that directly map to hardware implementation. The new features provided by this class are:

  • Support for arbitrary bit width (not restricted to multiples of 8 bits)
  • Support for a binary point, including automatic scaling
  • Methods for conversion to and from native floating point types
  • Build-in methods for resizing operations such as truncation, rounding, saturation, etc.
  • Overloaded operators for basic arithmetic (multiplication and addition) with automatic resizing of result
  • Strict size checking on assignment (rhs must have same size as lhs of assignment)

Well-defined width and check on assignment

All fixed point objects have a well-defined width property. In most cases, the width is immutable on assignment. When a FixedPoint object of width a is assigned to a FixedPoint object with width b != a, an exception is thrown and the assignment fails. However there are some special cases where the width can be mutable on assignment. For example, when an array of type FixedPoint is created FixedPoint *fxpArray = new FixedPoint[10]; the default constructor is invoked, however the default width of the FixedPoint objects constructed may not be the desired width.

Clone this wiki locally