mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Clarify truncation with addresses
This commit is contained in:
parent
da6cefd475
commit
22a2f5dd1d
@ -104,6 +104,14 @@ Operators:
|
||||
|
||||
* ``<=``, ``<``, ``==``, ``!=``, ``>=`` and ``>``
|
||||
|
||||
.. warning::
|
||||
If you convert a type that uses a larger byte size to an ``address``, for example ``bytes32``, then the ``address`` is truncated.
|
||||
To reduce conversion ambiguity version 0.4.24 and higher of the compiler force you make the truncation explicit in the conversion.
|
||||
Take for example the address ``0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFFCCCC``.
|
||||
|
||||
You can use ``address(uint160(bytes20(b)))``, which results in ``0x111122223333444455556666777788889999aAaa``,
|
||||
or you can use ``address(uint160(uint256(b)))``, which results in ``0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc``.
|
||||
|
||||
.. note::
|
||||
Starting with version 0.5.0 contracts do not derive from the address type, but can still be explicitly converted to address.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user