add test of setArrayMask

dev
MITSUNARI Shigeo 10 years ago
parent 02f726aad2
commit 6c8b2e7bb8
  1. 6
      src/fp.cpp
  2. 1
      test/fp_test.cpp

@ -322,11 +322,7 @@ void copyAndMask(Unit *y, const void *x, size_t xByteSize, const Op& op, bool do
if (compareArray(y, op.p, op.N) >= 0) throw cybozu::Exception("fp:copyAndMask:large x");
return;
}
/*
x &= mask(op.bitSize - 1);
*/
const Unit r = op.bitSize % UnitBitSize;
y[op.N - 1] &= r ? (Unit(1) << (r - 1)) - 1 : Unit(-1);
maskArray(y, op.N, op.bitSize - 1);
assert(compareArray(y, op.p, op.N) < 0);
}

@ -347,6 +347,7 @@ CYBOZU_TEST_AUTO(setArrayMask)
{ { 0x234567a4, 0x00000001, 0x00100000}, 1, "0x234567a4" },
{ { 0x234567a4, 0x00000001, 0x00100000}, 2, "0x1234567a4" },
{ { 0x234567a4, 0x00000001, 0x00100000}, 3, "0x00000000000001234567a4" },
{ { 0x234567a5, 0xfffffff1, 0xffffffff}, 3, "0x0ffffffffffff1234567a5" },
};
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
x.setArrayMask(tbl[i].buf, tbl[i].bufN);

Loading…
Cancel
Save