mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Updated docs for type(X).min and type(X).max
This commit is contained in:
parent
e4e200f29f
commit
091abcea8c
@ -122,6 +122,8 @@ Global Variables
|
||||
- ``type(C).creationCode`` (``bytes memory``): creation bytecode of the given contract, see :ref:`Type Information<meta-type>`.
|
||||
- ``type(C).runtimeCode`` (``bytes memory``): runtime bytecode of the given contract, see :ref:`Type Information<meta-type>`.
|
||||
- ``type(I).interfaceId`` (``bytes4``): value containing the EIP-165 interface identifier of the given interface, see :ref:`Type Information<meta-type>`.
|
||||
- ``type(X).min`` (``X``): the minimum value representable by the integer type ``X``, see :ref:`Type Information<meta-type>`.
|
||||
- ``type(X).max`` (``X``): the maximum value representable by the integer type ``X``, see :ref:`Type Information<meta-type>`.
|
||||
|
||||
.. note::
|
||||
Do not rely on ``block.timestamp``, ``now`` and ``blockhash`` as a source of randomness,
|
||||
|
@ -40,6 +40,9 @@ Operators:
|
||||
* Shift operators: ``<<`` (left shift), ``>>`` (right shift)
|
||||
* Arithmetic operators: ``+``, ``-``, unary ``-``, ``*``, ``/``, ``%`` (modulo), ``**`` (exponentiation)
|
||||
|
||||
For an integer type ``X``, you can use ``type(X).min`` and ``type(X).max`` to
|
||||
access the minimum and maximum value representable by the type.
|
||||
|
||||
.. warning::
|
||||
|
||||
Integers in Solidity are restricted to a certain range. For example, with ``uint32``, this is ``0`` up to ``2**32 - 1``.
|
||||
|
@ -294,10 +294,11 @@ Furthermore, all functions of the current contract are callable directly includi
|
||||
Type Information
|
||||
----------------
|
||||
|
||||
The expression ``type(X)`` can be used to retrieve information about the
|
||||
type ``X``. Currently, there is limited support for this feature, but
|
||||
it might be expanded in the future. The following properties are
|
||||
available for a contract type ``C``:
|
||||
The expression ``type(X)`` can be used to retrieve information about the type
|
||||
``X``. Currently, there is limited support for this feature (``X`` can be either
|
||||
a contract or an integer type) but it might be expanded in the future.
|
||||
|
||||
The following properties are available for a contract type ``C``:
|
||||
|
||||
``type(C).name``
|
||||
The name of the contract.
|
||||
@ -328,3 +329,10 @@ for an interface type ``I``:
|
||||
interface identifier of the given interface ``I``. This identifier is defined as the ``XOR`` of all
|
||||
function selectors defined within the interface itself - excluding all inherited functions.
|
||||
|
||||
The following properties are available for an integer type ``I``:
|
||||
|
||||
``type(I).min``
|
||||
The smallest value representable by type ``I``.
|
||||
|
||||
``type(I).max``
|
||||
The largest value representable by type ``I``.
|
||||
|
Loading…
Reference in New Issue
Block a user