Skip to content

Commit 2deff36

Browse files
committed
Added two's complement autotests
1 parent 59a7827 commit 2deff36

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/FixMath_Autotests.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ namespace FixMathPrivate {
3737
static_assert((e + e).getNF() == 2);
3838
static_assert((d + e).getNI() == 11);
3939

40+
// Two's complement peculiar additions
41+
static_assert(SFixAuto<-128>().getNI() == 7);
42+
static_assert(SFixAuto<127>().getNI() == 7);
43+
static_assert(SFixAuto<128>().getNI() == 8);
44+
45+
constexpr auto s = UFix<7,0>(-128);
46+
static_assert((s+s).getNI() == 8);
47+
4048
// the point of this block is to ascertain that addtion does not overflow, internally, where the internal_type of the operands is too small to hold the result
4149
constexpr auto large = UFix<32,0>(1LL << 31, true);
4250
static_assert(sizeof(decltype(large.asRaw())) == 4);

0 commit comments

Comments
 (0)