aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-12 18:11:13 +0800
committerGitHub <noreply@github.com>2017-07-12 18:11:13 +0800
commitb981ef2055cd8aa0bb1c6d4a58d547c78c509128 (patch)
treeb2fb4007f283d66318badde91ff1d8351d9d1d6c /docs
parent699a3724ae57168578dbc9844ca20c4af1ed7bcf (diff)
parent3149b7b2109229c3536dabd572d762d92db2fed0 (diff)
downloaddexon-solidity-b981ef2055cd8aa0bb1c6d4a58d547c78c509128.tar.gz
dexon-solidity-b981ef2055cd8aa0bb1c6d4a58d547c78c509128.tar.zst
dexon-solidity-b981ef2055cd8aa0bb1c6d4a58d547c78c509128.zip
Merge pull request #1477 from ethereum/doc-remove-fixed
[WIP] docs: ``var x = 1/4`` is not working, so remove description about it
Diffstat (limited to 'docs')
-rw-r--r--docs/types.rst18
1 files changed, 2 insertions, 16 deletions
diff --git a/docs/types.rst b/docs/types.rst
index 319701c7..67549499 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -222,14 +222,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
@@ -243,20 +235,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
::