Releases: Pharap/FixedPointsArduino
Fix bug in SFixed conversion operator
What's Changed
Full Changelog: v1.1.1...v1.1.2
Fix a bug in floating point conversion.
This release consists of just a single bug-fix: fixing conversion to float
(and double
) for certain types.
First minor release
Technically some of the earlier patch releases should have been minor releases, but I wasn't expecting this library to get as popular as it has done. I'm now aiming to stick to semver as much as possible.
This release contains several new features and one bugfix.
Features include:
- Operators for converting between
SFixed
andUFixed
types.- This change was long overdue, but I am satisfied that the chosen implementation is better than what I might have come up with a few years ago.
- Integer conversion operators
- Ooperators for converting to all of the built-in integer types (
char
,short
,int
,long
,long long
and allsigned
andunsigned
variations thereupon). - These are all explicit operators because conversion from fixed point to integer is an inherantly narrowing operation.
- Ooperators for converting to all of the built-in integer types (
- Postincrement and postdecrement operators.
- They are provided for completeness, though I would advise against using them.
- Bitwise shift operators.
- These have been added purely to facilitate cheaper and faster multiplication and division by powers of two. Personally I'm not a fan of using bitshift operators for this purpose because I believe it harms readability, but since it's unlikely that a compiler would be able to perform such an optimisation on a user-defined type and I expect most users of this library are targetting microcontrollers, I've decided that the potential memory savings are worth the harmed readability.
Bugfixes include:
++
and--
would cause a shift overflow for larger types because a lone1
was being treated asint
instead of a suitably large type. This was more of a problem for AVR CPUs, whereint
is only 16 bits wide.
Fix the random number issue for non-AVR targets
Most of the changes in this release are non-eventful behind the scenes stuff.
The biggest change is that now random number support is disabled for all non-AVR targets instead of being conditionally disabled for particular targets.
I.e. it is now assumed that a non-AVR target does not support random()
and thus random number facilities are not provided.
Random numbers may be provided for non-AVR targets in a future version, but for now they are off the table until more pressing issues have been handled. (That is, unless a particular need for them arises.)
Fix roundFixed, incorrect constant definitions and missing type conversion
Public API:
- Fixed unintended bug in
roundFixed
introduced in v1.0.5 (i.e. only v1.0.5 and v1.0.6 have this bug) - Fixed the definition of
UFixed::Scale
andSFixed::Scale
- Fixed an inconsistency with the typing of
SFixed
's constants compared toUFixed
- Added
long double
conversion operator (this is classed as a bugfix because its absense was an oversight)
Internal:
- Updated licence year
- Updated licence text
- Removed superfluous constructors
- Reorganised member constants and member type aliases
- Removed
UFixedBase
andSFixedBase
*
* This is a non-breaking change because UFixedBase
and SFixedBase
are not part of the public API. If this breaks your code, please re-read 'Important.txt'.
Added Teensy Support
- Added support for Teensy on request of @barafael.
- Added better error messages for unsuitable multiplication operations on request of @nunovilhena.
- Added an FAQ mentioning the multiplication issue to
README.md
. - Added a project showcase to
README.md
. - Removed inferred literal types.
Special thanks to @barafael for testing the Teensy support.
Added Arduino Due support
- Added support for Arduino Due on request of @coolpluggy. (Should work for other SAM boards.)
- Added
Serial.begin(9600);
toexamples/FixedPointCalculations
. - Simplified the definitions of
roundFixed
, which should reduce the generated code size.
Special thanks to @adekto for testing the Arduino Due support.
Added ESP8266 support
- Added support for ESP8266 on request of @marciopamplona.
- Added
FIXED_POINTS_NO_RANDOM
option to disable random number functions. - Added workaround for gcc bug 58541.
Special thanks to @eried for testing the ESP8266 support.
Added licence header to all relevant files
This update is mostly cosmetic and partly to make licencing clearer.
Now all relevant source files will have the Apache 2.0 licence header at the top.
Added PlatformIO support
Added support for PlatformIO on request of @yinkou (a.k.a. Botisaurus).