mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Set default fixed point decimal places to 18
This commit is contained in:
parent
be261ed519
commit
e37b619593
@ -54,7 +54,7 @@ The following elementary types exist:
|
||||
|
||||
- ``ufixed<M>x<N>``: unsigned variant of ``fixed<M>x<N>``.
|
||||
|
||||
- ``fixed``, ``ufixed``: synonyms for ``fixed128x19``, ``ufixed128x19`` respectively. For computing the function selector, ``fixed128x19`` and ``ufixed128x19`` have to be used.
|
||||
- ``fixed``, ``ufixed``: synonyms for ``fixed128x18``, ``ufixed128x18`` respectively. For computing the function selector, ``fixed128x18`` and ``ufixed128x18`` have to be used.
|
||||
|
||||
- ``bytes<M>``: binary type of ``M`` bytes, ``0 < M <= 32``.
|
||||
|
||||
@ -164,9 +164,9 @@ on the type of ``X`` being
|
||||
- ``int<M>``: ``enc(X)`` is the big-endian two's complement encoding of ``X``, padded on the higher-order (left) side with ``0xff`` for negative ``X`` and with zero bytes for positive ``X`` such that the length is 32 bytes.
|
||||
- ``bool``: as in the ``uint8`` case, where ``1`` is used for ``true`` and ``0`` for ``false``
|
||||
- ``fixed<M>x<N>``: ``enc(X)`` is ``enc(X * 10**N)`` where ``X * 10**N`` is interpreted as a ``int256``.
|
||||
- ``fixed``: as in the ``fixed128x19`` case
|
||||
- ``fixed``: as in the ``fixed128x18`` case
|
||||
- ``ufixed<M>x<N>``: ``enc(X)`` is ``enc(X * 10**N)`` where ``X * 10**N`` is interpreted as a ``uint256``.
|
||||
- ``ufixed``: as in the ``ufixed128x19`` case
|
||||
- ``ufixed``: as in the ``ufixed128x18`` case
|
||||
- ``bytes<M>``: ``enc(X)`` is the sequence of bytes in ``X`` padded with trailing zero-bytes to a length of 32 bytes.
|
||||
|
||||
Note that for any ``X``, ``len(enc(X))`` is a multiple of 32.
|
||||
|
@ -81,7 +81,7 @@ Fixed Point Numbers
|
||||
|
||||
``fixed`` / ``ufixed``: Signed and unsigned fixed point number of various sizes. Keywords ``ufixedMxN`` and ``fixedMxN``, where ``M`` represents the number of bits taken by
|
||||
the type and ``N`` represents how many decimal points are available. ``M`` must be divisible by 8 and goes from 8 to 256 bits. ``N`` must be between 0 and 80, inclusive.
|
||||
``ufixed`` and ``fixed`` are aliases for ``ufixed128x19`` and ``fixed128x19``, respectively.
|
||||
``ufixed`` and ``fixed`` are aliases for ``ufixed128x18`` and ``fixed128x18``, respectively.
|
||||
|
||||
Operators:
|
||||
|
||||
|
@ -208,9 +208,9 @@ TypePointer Type::fromElementaryTypeName(ElementaryTypeNameToken const& _type)
|
||||
case Token::UInt:
|
||||
return make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned);
|
||||
case Token::Fixed:
|
||||
return make_shared<FixedPointType>(128, 19, FixedPointType::Modifier::Signed);
|
||||
return make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Signed);
|
||||
case Token::UFixed:
|
||||
return make_shared<FixedPointType>(128, 19, FixedPointType::Modifier::Unsigned);
|
||||
return make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Unsigned);
|
||||
case Token::Byte:
|
||||
return make_shared<FixedBytesType>(1);
|
||||
case Token::Address:
|
||||
|
@ -2452,8 +2452,8 @@ BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName)
|
||||
BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 31, 0)) == *make_shared<FixedBytesType>(31));
|
||||
BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 32, 0)) == *make_shared<FixedBytesType>(32));
|
||||
|
||||
BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Fixed, 0, 0)) == *make_shared<FixedPointType>(128, 19, FixedPointType::Modifier::Signed));
|
||||
BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixed, 0, 0)) == *make_shared<FixedPointType>(128, 19, FixedPointType::Modifier::Unsigned));
|
||||
BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Fixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Signed));
|
||||
BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Unsigned));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_byte_is_alias_of_byte1)
|
||||
@ -4471,7 +4471,7 @@ BOOST_AUTO_TEST_CASE(invalid_int_implicit_conversion_from_fixed)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Type fixed128x19 is not implicitly convertible to expected type int256");
|
||||
CHECK_ERROR(text, TypeError, "Type fixed128x18 is not implicitly convertible to expected type int256");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(rational_unary_operation)
|
||||
@ -4589,7 +4589,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_invalid_implicit_conversion_size)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Type ufixed128x19 is not implicitly convertible to expected type ufixed248x8");
|
||||
CHECK_ERROR(text, TypeError, "Type ufixed128x18 is not implicitly convertible to expected type ufixed248x8");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(fixed_type_invalid_implicit_conversion_lost_data)
|
||||
@ -4676,7 +4676,7 @@ BOOST_AUTO_TEST_CASE(fixed_to_bytes_implicit_conversion)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "fixed128x19 is not implicitly convertible to expected type bytes32");
|
||||
CHECK_ERROR(text, TypeError, "fixed128x18 is not implicitly convertible to expected type bytes32");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(mapping_with_fixed_literal)
|
||||
|
Loading…
Reference in New Issue
Block a user