Skip to content

Commit 4da0bfd

Browse files
committed
Merge branch 'develop'
2 parents 74e8cbe + b35cadb commit 4da0bfd

19 files changed

+1125
-615
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
build/
1+
build/
2+
cmake-build-debug/
3+
.idea/workspace.xml

.idea/MFixedPoint.iml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/Project.xml

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [v8.0.0] - 2018-02-12
10+
11+
### Added
12+
- Added CLion project files, closes 92.
13+
- Added overload support for printing To ostream using '<<' (and a 'ToString()' method), closes #67.
14+
- Added unit tests for arithmetic between 'FpF' and 'int' objects.
15+
16+
### Fixed
17+
- Fixed bug where code coverage library was looked for even if COVERAGE set to false, closes #91.
18+
- Removed un-used 'CountLeadingZeros()' and 'fixinv()' functions from 'FpF.hpp'.
19+
- Improved speed of FpF division and fixed incorrect result when BaseType was greater than 32 bits, closes #93.
20+
921
## [v8.0.0-beta.2] - 2018-01-11
1022

1123
### Added
@@ -50,7 +62,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5062
- Changed the `Fp` namespace to `MFixedPoint` (to reflect actual project name), closes #86.
5163
- Modified header guard macros to include the text `MN_MFIXEDPOINT_...` (to include organization/project name).
5264

53-
[Unreleased]: https://github.com/mbedded-ninja/CppTemplate/compare/v8.0.0-beta.2...HEAD
65+
[Unreleased]: https://github.com/mbedded-ninja/CppTemplate/compare/v8.0.0...HEAD
66+
[v8.0.0]: https://github.com/mbedded-ninja/CppTemplate/compare/v8.0.0-beta.2...v8.0.0
5467
[v8.0.0-beta.2]: https://github.com/mbedded-ninja/CppTemplate/compare/v8.0.0-beta.1...v8.0.0-beta.2
5568
[v8.0.0-beta.1]: https://github.com/mbedded-ninja/CppTemplate/compare/v7.0.1...v8.0.0-beta.1
5669
[v7.0.1]: https://github.com/mbedded-ninja/CppTemplate/compare/v7.0.0...v7.0.1

README.rst

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,31 @@ Conversion/Casting:
9393
// Direct casting is also supported
9494
printf("(int32_t)fp1 = %i\n", (int32_t)fp1); // Prints "(int32_t)fp1 = 2"
9595
printf("(double)fp1 = %.2f\n", (double)fp1); // Prints "(double)fp1 = 2.22"
96-
9796
98-
Overflows
99-
---------
97+
String/Stream Support:
10098

101-
:code:`FpS8, FpS16, FpS32` are protected from intermediary overflows. :code:`FpS64` is not, due to the lack of a :code:`int128_t` type on most embeded platforms.
99+
:code:`FpS` provides a :code:`ToString()` method, as well as supporting a :code:`ostream` (e.g. :code:`std::cout`).
102100

103-
On any 32-bit architecture, :code:`FpS64` numbers will be slower than :code:`FpS64` numbers. Use only if 32-bit numbers don't offer the range/precision required.
101+
.. code:: cpp
102+
103+
FpS32 fp1(4.87, 8);
104+
printf(fp1.ToString());
105+
std::cout << fp1 << std::endl; // Prints 4.87
104106
105107
The "Fast" Fixed-Point Library (FpF)
106108
------------------------------------
107109

108-
The number of fractional bits is given as a template parameter (e.g. :code:`FpF<int32_t, 12>(3.4)` will create the number 3.4 with 12 bits of decimal precision). It is not stored in the fixed-point object. This gives the fastest possible arithmetic speeds, at the expense of loosing some functionality and a tad more code space.
110+
The number of fractional bits is given as a template parameter (e.g. :code:`FpF32<12>(3.4)` will create the number 3.4 with 12 bits of fractional precision). It is not stored in the fixed-point object. This gives the fastest possible arithmetic speeds, at the expense of loosing some functionality and a tad more code space.
111+
112+
Arithmetic operations between two FpF objects that have a different template parameter (fractional precision) is not directly supported. Instead, you will have to convert one of the FpF objects to the same fraction precision first, and then do the arithmetic operation.
113+
114+
Overflows
115+
---------
116+
117+
:code:`FpS8, FpS16, FpS32` are protected from intermediary overflows. :code:`FpS64` is not, due to the lack of a :code:`int128_t` type on most embeded platforms.
118+
119+
On any 32-bit architecture, :code:`FpS64` numbers will be slower than :code:`FpS64` numbers. Use only if 32-bit numbers don't offer the range/precision required.
109120

110-
You have to be aware that when adding numbers with different Q, you have to perform the bit-shifting yourself. Also, if you want to convert a fast fixed-point number to a double, you cannot use a cast (e.g. :code:`(double)myFp32fNum` won't work, you have to use provided functions (e.g. :code:`Fix32ToDouble(myFp32fNum);`).
111121

112122
Benchmarking
113123
============
@@ -116,6 +126,20 @@ This library contains a benchmarking program in :code:`benchmark/` which runs op
116126

117127
The benchmarking is compared to software-based float arithmetic (using the custom header SoftFloat.hpp), since most benchmarking will be run on a development computer which has an FPU which will be used if float + float was written in code. If benchmarking on a device which does not have an FPU, you should compare the fixed-point operations against the native software float arithmetic implementation instead. Software-based 32-bit float addition and multiplication are performed and compared with the equivalent fixed-point operations.
118128

129+
These benchmark results were computed on a x64 Ubuntu machine running inside a virtual machine. 100k samples were taken for each type of test, and the average time provided.
130+
131+
+----------------+--------+--------+--------+--------+----------------+----------------+
132+
| Arithmetic | FpF32 | FpF64 | FpS32 | FpS64 | Software Float | Hardware Float |
133+
+================+========+========+========+========+================+================+
134+
| Addition | 6.7ns | 8.2ns | 10.6ns | 14.2ns | 30.1ns | 3.4ns |
135+
+----------------+--------+--------+--------+--------+----------------+----------------+
136+
| Subtraction | 7.5ns | 7.5ns | 14.0ns | 10.4ns | n/a | 2.6ns |
137+
+----------------+--------+--------+--------+--------+----------------+----------------+
138+
| Multiplication | 10.3ns | 10.1ns | 12.2ns | 10.4ns | 32.0ns | 2.5ns |
139+
+----------------+--------+--------+--------+--------+----------------+----------------+
140+
| Division | 19.0ns | 18.0ns | 10.8ns | 19.8ns | n/a | 5.1ns |
141+
+----------------+--------+--------+--------+--------+----------------+----------------+
142+
119143
Platform Independent
120144
====================
121145

0 commit comments

Comments
 (0)