Skip to content

Commit

Permalink
docs: floordiv (#3797)
Browse files Browse the repository at this point in the history
add docs for floordiv

* add note on rounding for negative integers

---------

Co-authored-by: Charles Cooper <cooper.charles.m@gmail.com>
  • Loading branch information
tserg and charles-cooper committed Feb 21, 2024
1 parent 015cf81 commit 21a511a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Operator Description
``x - y`` Subtraction
``-x`` Unary minus/Negation
``x * y`` Multiplication
``x / y`` Division
``x // y`` Integer division
``x**y`` Exponentiation
``x % y`` Modulo
============= ======================
Expand Down Expand Up @@ -131,6 +131,8 @@ Shifting is only available for 256-bit wide types. That is, ``x`` must be ``int2
.. note::
While at runtime shifts are unchecked (that is, they can be for any number of bits), to prevent common mistakes, the compiler is stricter at compile-time and will prevent out of bounds shifts. For instance, at runtime, ``1 << 257`` will evaluate to ``0``, while that expression at compile-time will raise an ``OverflowException``.

.. note::
Integer division has different rounding semantics than Python for negative numbers: Vyper rounds towards zero, while Python rounds towards negative infinity. For example, ``-1 // 2` will return ``-1`` in Python, but ``0`` in Vyper.

.. index:: ! uint, ! uintN, ! unsigned integer

Expand Down Expand Up @@ -181,7 +183,7 @@ Operator Description
``x + y`` Addition
``x - y`` Subtraction
``x * y`` Multiplication
``x / y`` Division
``x // y`` Integer division
``x**y`` Exponentiation
``x % y`` Modulo
=========================== ======================
Expand Down Expand Up @@ -270,7 +272,7 @@ Operator Description
``x - y`` Subtraction
``-x`` Unary minus/Negation
``x * y`` Multiplication
``x / y`` Division
``x / y`` Decimal division
``x % y`` Modulo
============= ==========================================

Expand Down

0 comments on commit 21a511a

Please sign in to comment.