aboutsummaryrefslogtreecommitdiffstats
path: root/include/mcl
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-05-22 03:24:19 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-05-22 03:24:19 +0800
commitdc2a87192680a4cb01dbe8f9e150a8ea3370efb2 (patch)
tree8d10b80aa770cab4fde335626a5cc85b8c22f970 /include/mcl
parentcee117c2d06ed90e85f140437af162bdcc31b8ad (diff)
downloadtangerine-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.hpp21
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)