From c975bf87db9e41014af70d74dd48514b5783c30f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 29 Aug 2017 21:26:39 +0100 Subject: [PATCH 1/3] Move fixed after int in docs --- docs/types.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/types.rst b/docs/types.rst index aa4589de5..b8d387b2b 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -70,6 +70,15 @@ sign extends. Shifting by a negative amount throws a runtime exception. are going to be rounded towards zero (truncated). In other programming languages the shift right of negative values works like division with rounding down (towards negative infinity). +.. index:: ! ufixed, ! fixed, ! fixed point number + +Fixed Point Numbers +------------------- + +.. warning:: + Fixed point numbers are not fully supported by Solidity yet. They can be declared, but + cannot be assigned to or from. + .. index:: address, balance, send, call, callcode, delegatecall, transfer .. _address: @@ -181,15 +190,6 @@ As a rule of thumb, use ``bytes`` for arbitrary-length raw byte data and ``strin for arbitrary-length string (UTF-8) data. If you can limit the length to a certain number of bytes, always use one of ``bytes1`` to ``bytes32`` because they are much cheaper. -.. index:: ! ufixed, ! fixed, ! fixed point number - -Fixed Point Numbers -------------------- - -.. warning:: - Fixed point numbers are not fully supported by Solidity yet. They can be declared, but - cannot be assigned to or from. - .. index:: address, literal;address .. _address_literals: From 76bd8c57694b9335dc5ce29204f57825b4a565eb Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 29 Aug 2017 21:38:41 +0100 Subject: [PATCH 2/3] Explain fixed point types --- docs/types.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/types.rst b/docs/types.rst index b8d387b2b..d1b5a3f1b 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -79,6 +79,15 @@ Fixed Point Numbers Fixed point numbers are not fully supported by Solidity yet. They can be declared, but cannot be assigned to or from. +``fixed`` / ``ufixed``: Signed and unsigned fixed point number of various sizes. Keywords ``ufixedMxN`` and ``fixedMxN``, where ``M`` represent the number of bits taken by +the type and ``N`` represent 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. + +Operators: + +* Comparisons: ``<=``, ``<``, ``==``, ``!=``, ``>=``, ``>`` (evaluate to ``bool``) +* Arithmetic operators: ``+``, ``-``, unary ``-``, unary ``+``, ``*``, ``/``, ``%`` (remainder) + .. index:: address, balance, send, call, callcode, delegatecall, transfer .. _address: From 435eeec5e15d94ffc2dff01dd09c8c92c697dc4e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 29 Aug 2017 21:38:54 +0100 Subject: [PATCH 3/3] Explain the difference between floating and fixed point --- docs/frequently-asked-questions.rst | 5 ----- docs/types.rst | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index 5f1a981ea..d9a68ed13 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -103,11 +103,6 @@ This is a limitation of the EVM and will be solved with the next protocol update Returning variably-sized data as part of an external transaction or call is fine. -How do you represent ``double``/``float`` in Solidity? -====================================================== - -This is not yet possible. - Is it possible to in-line initialize an array like so: ``string[] myarray = ["a", "b"];`` ========================================================================================= diff --git a/docs/types.rst b/docs/types.rst index d1b5a3f1b..71a4b0e66 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -88,6 +88,12 @@ Operators: * Comparisons: ``<=``, ``<``, ``==``, ``!=``, ``>=``, ``>`` (evaluate to ``bool``) * Arithmetic operators: ``+``, ``-``, unary ``-``, unary ``+``, ``*``, ``/``, ``%`` (remainder) +.. note:: + The main difference between floating point (``float`` and ``double`` in many languages, more precisely IEEE 754 numbers) and fixed point numbers is + that the number of bits used for the integer and the fractional part (the part after the decimal dot) is flexible in the former, while it is strictly + defined in the latter. Generally, in floating point almost the entire space is used to represent the number, while only a small number of bits define + where the decimal point is. + .. index:: address, balance, send, call, callcode, delegatecall, transfer .. _address: