Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:ac99b6f474a0, committed 2011-11-27
- Comitter:
- madcowswe
- Date:
- Sun Nov 27 05:10:45 2011 +0000
- Parent:
- 0:ca79fb4a8165
- Commit message:
- Made it possible to cast to double
Changed in this revision
| fixed_class.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/fixed_class.h Sun Nov 27 00:28:31 2011 +0000
+++ b/fixed_class.h Sun Nov 27 05:10:45 2011 +0000
@@ -80,10 +80,11 @@
fixed_point operator / (int32_t r) const { fixed_point x = *this; x /= r; return x;}
operator int() const { return intValue>>p; }
operator float() const { return fix2float<p>(intValue); }
+ operator double() const { return (double)intValue / (1 << p); }
//Added casting and constructing from another precision
template <int q>
- fixed_point(const fixed_point<q> &r) : intValue(q <= p ? r.intValue << (p - q) : r.intValue >> (q - p)) {}
+ fixed_point(const fixed_point<q> &r) : intValue(q <= p ? r.intValue << (p - q) : r.intValue >> (q - p)) {}
};
// Specializations for use with plain integers