aboutsummaryrefslogtreecommitdiffstats
path: root/docs/types.rst
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-12-02 22:26:15 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-12-02 22:28:19 +0800
commit3149b7b2109229c3536dabd572d762d92db2fed0 (patch)
tree633609d00d3b0362a14f30a7c0362ecf95d641a4 /docs/types.rst
parent3a01a87afe3468421f31aa5097796dcc88e37e26 (diff)
downloaddexon-solidity-3149b7b2109229c3536dabd572d762d92db2fed0.tar.gz
dexon-solidity-3149b7b2109229c3536dabd572d762d92db2fed0.tar.zst
dexon-solidity-3149b7b2109229c3536dabd572d762d92db2fed0.zip
docs: ``var x = 1/4`` is not working, so remove description about it
Diffstat (limited to 'docs/types.rst')
-rw-r--r--docs/types.rst18
1 files changed, 2 insertions, 16 deletions
diff --git a/docs/types.rst b/docs/types.rst
index 896910ff..b17a2771 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -186,14 +186,6 @@ For example, ``(2**800 + 1) - 2**800`` results in the constant ``1`` (of type ``
although intermediate results would not even fit the machine word size. Furthermore, ``.5 * 8`` results
in the integer ``4`` (although non-integers were used in between).
-If the result is not an integer,
-an appropriate ``ufixed`` or ``fixed`` type is used whose number of fractional bits is as large as
-required (approximating the rational number in the worst case).
-
-In ``var x = 1/4;``, ``x`` will receive the type ``ufixed0x8`` while in ``var x = 1/3`` it will receive
-the type ``ufixed0x256`` because ``1/3`` is not finitely representable in binary and will thus be
-approximated.
-
Any operator that can be applied to integers can also be applied to number literal expressions as
long as the operands are integers. If any of the two is fractional, bit operations are disallowed
and exponentiation is disallowed if the exponent is fractional (because that might result in
@@ -207,20 +199,14 @@ a non-rational number).
types. So the number literal expressions `1 + 2` and `2 + 1` both
belong to the same number literal type for the rational number three.
-.. note::
- Most finite decimal fractions like ``5.3743`` are not finitely representable in binary. The correct type
- for ``5.3743`` is ``ufixed8x248`` because that allows to best approximate the number. If you want to
- use the number together with types like ``ufixed`` (i.e. ``ufixed128x128``), you have to explicitly
- specify the desired precision: ``x + ufixed(5.3743)``.
-
.. warning::
Division on integer literals used to truncate in earlier versions, but it will now convert into a rational number, i.e. ``5 / 2`` is not equal to ``2``, but to ``2.5``.
.. note::
Number literal expressions are converted into a non-literal type as soon as they are used with non-literal
expressions. Even though we know that the value of the
- expression assigned to ``b`` in the following example evaluates to an integer, it still
- uses fixed point types (and not rational number literals) in between and so the code
+ expression assigned to ``b`` in the following example evaluates to
+ an integer, but the partial expression ``2.5 + a`` does not type check so the code
does not compile
::