diff options
author | VoR0220 <catalanor0220@gmail.com> | 2016-03-29 02:36:48 +0800 |
---|---|---|
committer | VoR0220 <catalanor0220@gmail.com> | 2016-05-10 00:41:02 +0800 |
commit | 4d283b2b304f9c9a85fb6f03346cc7c9d0054daa (patch) | |
tree | acaa0533f4b69037874563fbee97e8fea709cff8 | |
parent | 93295ae8f8e92d075584d10ac21374f83c43f759 (diff) | |
download | dexon-solidity-4d283b2b304f9c9a85fb6f03346cc7c9d0054daa.tar dexon-solidity-4d283b2b304f9c9a85fb6f03346cc7c9d0054daa.tar.gz dexon-solidity-4d283b2b304f9c9a85fb6f03346cc7c9d0054daa.tar.bz2 dexon-solidity-4d283b2b304f9c9a85fb6f03346cc7c9d0054daa.tar.lz dexon-solidity-4d283b2b304f9c9a85fb6f03346cc7c9d0054daa.tar.xz dexon-solidity-4d283b2b304f9c9a85fb6f03346cc7c9d0054daa.tar.zst dexon-solidity-4d283b2b304f9c9a85fb6f03346cc7c9d0054daa.zip |
currently what we have
-rw-r--r-- | libsolidity/ast/Types.cpp | 12 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index c9df0086..e4f2b035 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -817,7 +817,7 @@ shared_ptr<FixedPointType const> ConstantNumberType::fixedPointType() const bool negative = (m_value < 0); //todo: change name bigint fractionalBits = fractionalBitsNeeded(); - + cout << "Total int: " << fractionalBits.str() << endl; if (negative && !fractionalSignBit) // convert to positive number of same bit requirements { integers = ((0 - integers) - 1) << 1; @@ -830,10 +830,14 @@ shared_ptr<FixedPointType const> ConstantNumberType::fixedPointType() const return shared_ptr<FixedPointType const>(); else { - unsigned totalBytesRequired = bytesRequired(fractionalBits) * 8; + cout << "m_value: " << m_value << endl; + cout << "Total int: " << fractionalBits.str() << endl; + unsigned fractionalBytesRequired = bytesRequired(fractionalBits) * 8; unsigned integerBytesRequired = bytesRequired(integers) * 8; + cout << "Fractional Bytes Required: " << fractionalBytesRequired << endl; + cout << "Integer Bytes Required: " << integerBytesRequired << endl << endl; return make_shared<FixedPointType>( - integerBytesRequired, totalBytesRequired - integerBytesRequired, + integerBytesRequired, fractionalBytesRequired, negative ? FixedPointType::Modifier::Signed : FixedPointType::Modifier::Unsigned ); } @@ -842,7 +846,7 @@ shared_ptr<FixedPointType const> ConstantNumberType::fixedPointType() const //todo: change name of function bigint ConstantNumberType::fractionalBitsNeeded() const { - auto value = m_value; + auto value = m_value - wholeNumbers(); for (unsigned fractionalBits = 0; value < boost::multiprecision::pow(bigint(2), 256); fractionalBits += 8, value *= 10) { if (value.denominator() == 1) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 42d06fd7..90bb7065 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -3434,7 +3434,7 @@ BOOST_AUTO_TEST_CASE(inline_array_fixed_rationals) char const* text = R"( contract test { function f() { - ufixed8x16[3] memory a = [3.5, 4.1234, 2.5]; + ufixed8x16[4] memory a = [3.5, 4.1234, 2.5, 4.0]; } } )"; |