diff options
| author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-22 03:24:19 +0800 |
|---|---|---|
| committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-22 03:24:19 +0800 |
| commit | dc2a87192680a4cb01dbe8f9e150a8ea3370efb2 (patch) | |
| tree | 8d10b80aa770cab4fde335626a5cc85b8c22f970 /include/mcl | |
| parent | cee117c2d06ed90e85f140437af162bdcc31b8ad (diff) | |
| download | tangerine-mcl-dc2a87192680a4cb01dbe8f9e150a8ea3370efb2.tar.gz tangerine-mcl-dc2a87192680a4cb01dbe8f9e150a8ea3370efb2.tar.zst tangerine-mcl-dc2a87192680a4cb01dbe8f9e150a8ea3370efb2.zip | |
split getUint64/getInt64 for throw
Diffstat (limited to 'include/mcl')
| -rw-r--r-- | include/mcl/fp.hpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index b026d7c..f907a8c 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -364,8 +364,7 @@ public: *pb = false; return; } - setArray(gmp::getUnit(x), gmp::getUnitSize(x)); - *pb = true; + setArray(gmp::getUnit(x), gmp::getUnitSize(x), pb); } void setMpz(const mpz_class& x) { @@ -421,18 +420,32 @@ public: { return fp::isLessArray(v_, op_.p, op_.N); } - uint64_t getUint64(bool *pb = 0) const + uint64_t getUint64(bool *pb) const { fp::Block b; getBlock(b); return fp::getUint64(pb, b); } - int64_t getInt64(bool *pb = 0) const + int64_t getInt64(bool *pb) const { fp::Block b; getBlock(b); return fp::getInt64(pb, b, op_); } + uint64_t getUint64() const + { + bool b; + uint64_t v = getUint64(&b); + if (!b) throw cybozu::Exception("Fp:getUint64:large value"); + return v; + } + int64_t getInt64() const + { + bool b; + int64_t v = getInt64(&b); + if (!b) throw cybozu::Exception("Fp:getInt64:large value"); + return v; + } bool operator==(const FpT& rhs) const { return fp::isEqualArray(v_, rhs.v_, op_.N); } bool operator!=(const FpT& rhs) const { return !operator==(rhs); } friend inline std::ostream& operator<<(std::ostream& os, const FpT& self) |
