aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVoR0220 <rj@erisindustries.com>2016-09-10 10:03:23 +0800
committerVoR0220 <rj@erisindustries.com>2016-09-10 10:03:23 +0800
commitcbd933ceedc9d38df356856eec7bfca07d440523 (patch)
tree1afcc8f9bcaad8de4a50d2795dc6e573e961abd7 /test
parent51a98ab84a59fd5fb34378763fd9ed635cf06d8d (diff)
downloaddexon-solidity-cbd933ceedc9d38df356856eec7bfca07d440523.tar.gz
dexon-solidity-cbd933ceedc9d38df356856eec7bfca07d440523.tar.zst
dexon-solidity-cbd933ceedc9d38df356856eec7bfca07d440523.zip
Solidity helper function for testing fixed points
Signed-off-by: VoR0220 <rj@erisindustries.com>
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityExecutionFramework.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h
index 6cf7e0ee..a4181dfe 100644
--- a/test/libsolidity/SolidityExecutionFramework.h
+++ b/test/libsolidity/SolidityExecutionFramework.h
@@ -39,6 +39,7 @@ namespace dev
{
namespace solidity
{
+ using rational = boost::rational<dev::bigint>;
/// An Ethereum address: 20 bytes.
/// @NOTE This is not endian-specific; it's just a bunch of bytes.
using Address = h160;
@@ -186,7 +187,12 @@ public:
{
return encodeArgs(u256(0x20), u256(_arg.size()), _arg);
}
-
+ static u256 fixed(dev::bigint _numerator, dev::bigint _denominator, int _fixedBits)
+ {
+ rational _value = rational(dev::bigint(_numerator), dev::bigint(_denominator));
+ rational value = _value * boost::multiprecision::pow(bigint(2), _fixedBits);
+ return u256(value.numerator()/value.denominator());
+ }
class ContractInterface
{
public: