diff --git a/include/mcl/conversion.hpp b/include/mcl/conversion.hpp index 6fbd394..2383efd 100644 --- a/include/mcl/conversion.hpp +++ b/include/mcl/conversion.hpp @@ -5,7 +5,7 @@ #include /** @file - @brief utility of Fp + @brief convertion from T[] to str2, str16 @author MITSUNARI Shigeo(@herumi) @license modified new BSD license http://opensource.org/licenses/BSD-3-Clause diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index 43e8a1b..eccef53 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -20,6 +20,7 @@ // #define USE_MONT_FP #endif #include +#include #include #include #include @@ -240,11 +241,15 @@ public: FpT t(x); for (size_t i = 0; i < yn; i++) { const Unit v = y[i]; - int m = (int)sizeof(Unit) * 8; + int m = (int)fp::UnitBitN; if (i == yn - 1) { +#if 1 + m = v ? cybozu::bsr(v) + 1 : 0; +#else while (m > 0 && (v & (Unit(1) << (m - 1))) == 0) { m--; } +#endif } for (int j = 0; j < m; j++) { if (v & (Unit(1) << j)) { diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index e1b92a3..61fd548 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -6,7 +6,6 @@ @license modified new BSD license http://opensource.org/licenses/BSD-3-Clause */ -#include #include #ifndef MCL_MAX_OP_BIT_N diff --git a/include/mcl/util.hpp b/include/mcl/util.hpp index 4acb6d1..cd21ae4 100644 --- a/include/mcl/util.hpp +++ b/include/mcl/util.hpp @@ -1,7 +1,7 @@ #pragma once /** @file - @brief definition of Unit and some functions + @brief functions for T[] @author MITSUNARI Shigeo(@herumi) @license modified new BSD license http://opensource.org/licenses/BSD-3-Clause