This site is supported by donations to The OEIS Foundation.

Integer division

From OeisWiki
Jump to: navigation, search


This article page is a stub, please help by expanding it.


Integer division (or Euclidean division) is an operation on integers defined as

where
⌊ ·⌋
is the floor function. In the mapping
given by the division algorithm, the integer quotient[1]
q ∈ ℤ
, with
0   ≤   r <
| n |
as the remainder.[2]

Least absolute remainder

The least absolute remainder integer division (or nearest integer division) is an operation on integers defined as

where
sgn (n)
is the sign function. In the mapping
given by the [least absolute remainder] division algorithm, the nearest integer quotient
q ∈ ℤ
, with
 − 
⌊  
| n |
/2⌋
  ≤   r <
| n |
 − 
⌊  
| n |
/2⌋
as the least absolute remainder.

Examples

The allowed least absolute remainders
mod ±2
are
{ − 1, 0}
:
  • (7, 2)
    maps to
    (4, 7  −  4  ×  2) = (4,  − 1)
    , i.e.
    7 = 4  ×  2 + ( − 1)
    ;
  • ( − 7, 2)
    maps to
    ( − 3,  − 7  −  ( − 3)  ×  2) = ( − 3,  − 1)
    , i.e.
     − 7 = ( − 3)  ×  2 + ( − 1)
    ;
  • (7,  − 2)
    maps to
    ( − 4, 7  −  ( − 4)  ×  ( − 2)) = ( − 4,  − 1)
    , i.e.
    7 = ( − 4)  ×  ( − 2) + ( − 1)
    ;
  • ( − 7,  − 2)
    maps to
    (3,  − 7  −  3  ×  ( − 2) = (3,  − 1)
    , i.e.
     − 7 = 3  ×  ( − 2) + ( − 1)
    .
The allowed least absolute remainders
mod ±256
are
{ − 128, ...,  − 1, 0, 1, ..., 127}
:
  • (128, 256)
    maps to
    (1, 128  −  1  ×  256) = (1,  − 128)
    , i.e.
    128 = 1  ×  256 + ( − 128)
    ;
  • ( − 128, 256)
    maps to
    0,  − 128  −  0  ×  256) = (0,  − 128)
    , i.e.
     − 128 = 0  ×  256 + ( − 128)
    ;
  • (128,  − 256)
    maps to
    ( − 1, 128  −  ( − 1)  ×  ( − 256)) = ( − 1,  − 128)
    , i.e.
    128 = ( − 1)  ×  ( − 256) + ( − 128)
    ;
  • ( − 128,  − 256)
    maps to
    (0,  − 128  −  0  ×  ( − 256) = (0,  − 128)
    , i.e.
     − 128 = 0  ×  ( − 256) + ( − 128)
    .

See also

Notes

  1. Weisstein, Eric W., Quotient, from MathWorld—A Wolfram Web Resource. [http://mathworld.wolfram.com/Quotient.html]
  2. Weisstein, Eric W., Remainder, from MathWorld—A Wolfram Web Resource. [http://mathworld.wolfram.com/Remainder.html]