Skip to content

Commit 947351e

Browse files
authored
Merge pull request #14 from tomcombriat/work/fix_13
Bugfix in NI autoadjust
2 parents f967f9b + 3578cf4 commit 947351e

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/FixMath.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ class SFix
10731073
static constexpr int8_t getNF() {return NF;}
10741074

10751075

1076-
/** Check wether this number exceeds the given total size in bits. See UFix::asssertSize().
1076+
/** Check wether this number exceeds the given total size in bits. See UFix::assertSize().
10771077
*
10781078
* @note This function counts the number of bits needed, internally, and including the sign bit.
10791079
* E.g. SFix<8,0>::assertSize<8>() will fail, as it requires 9 bits, internally!
@@ -1083,7 +1083,7 @@ class SFix
10831083
template<int8_t, int8_t, uint64_t> friend class UFix; // for access to UFixNIadj_t
10841084
template<int8_t, int8_t, uint64_t> friend class SFix;
10851085
static constexpr uint64_t maxRANGE(int8_t delta_bits=0) { return (uint64_t(1)<<(NI+NF+delta_bits)); } // no -1 for signed, because negative number actually extend to -2^n, not just 2^n-1
1086-
typedef UFix<(RANGE > maxRANGE()) ? NI+1 : (RANGE > maxRANGE(-1)) ? NI : NI-1, NF, RANGE> SFixNIadj_t;
1086+
typedef SFix<(RANGE > maxRANGE()) ? NI+1 : (RANGE > maxRANGE(-1)) ? NI : NI-1, NF, RANGE> SFixNIadj_t;
10871087

10881088
internal_type internal_value;
10891089
//static constexpr internal_type onesbitmask() { return (internal_type) ((1ULL<< (NI+NF)) - 1); }

src/FixMath_Autotests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace FixMathPrivate {
5757
static_assert(SFix<4, 3>(-1) == SFix<4, 5>(-1)); // NOTE This is a simpler test case for the above problem. Note the difference in NF, which prompts shifting
5858
#endif
5959
// here's a variant that avoids the problem by using only positive numbers
60-
static_assert(UFix<12,1>(999) - UFix<43,9>(0) - b - a == UFix<19,3>(999) + (-(a+b)));
60+
static_assert(UFix<12,1>(999) - UFix<43,9>(0) - b - a == UFix<19,2>(999) + (-(a+b)));
6161
static_assert(-SFix<4, 3>(-8, true) == -SFix<4, 5>(-32, true));
6262

6363
// multiplication

0 commit comments

Comments
 (0)