Elm Exactly

Basis entryBasics.idiv

A value of Basics. Its type is in Section C.3 Basics.

Static basis

op stands for ↦ OTSTAT(op)// idiv ↦ (Int→Int→Int,v)\begin{array}{|clcl|}\hline \opv {\ }& \text{stands for} {\ }& \mapsto {\ }& \OTstat(\opv)\\\hline \kw{//} {\ }& \href{/standard/basis/Basics/idiv}{\kw{idiv}} {\ }& \mapsto {\ }& (\tInt \rightarrow \tInt \rightarrow \tInt, \isv)\\\hline\end{array}
Figure 40: The Static Operator Table, OTSTAT\OTstat

Dynamic basis

opstands for ↦ OTDYN(op)arity*, /, //mul, fdiv, idiv ↦ basic value2\begin{array}{|clclc|}\hline \opv {\quad}& \text{stands for} {\ }& \mapsto {\ }& \OTdyn(\opv) {\qquad}& \arity\\\hline \kw{*},\ \kw{/},\ \kw{//} {\quad}& \href{/standard/basis/Basics/mul}{\kw{mul}},\ \href{/standard/basis/Basics/fdiv}{\kw{fdiv}},\ \href{/standard/basis/Basics/idiv}{\kw{idiv}} {\ }& \mapsto {\ }& \text{basic value} {\qquad}& 2\\\hline\end{array}
Figure 46: The Dynamic Operator Table, OTDYN\OTdyn

Its APPLY

APPLY(idiv,m,n) = {norm(trunc(m/n))}if n≠0 = {0}if n=0\begin{array}{rcll} \APPLY(\kw{idiv},m,n) {\ }& = {\ }& \{\norm(\dbtrunc(m/n))\} {\quad}& \text{if}\ n\neq 0\\ {\ }& = {\ }& \{0\} {\quad}& \text{if}\ n=0\end{array}
Figure 49: APPLY\APPLY on Int Values
Read it in its chapter·Permanent address: /standard/basis/Basics/idiv

Tests (5)

  • elm / InfixAssocLeftArithTest
    `-`, `/` and `//` associate to the left.
  • elm-core / IntDivByZeroTest
    Checks that integer division `//` by zero gives 0, for a positive and for a negative dividend.
  • elm-core / IntDivTest
    Checks that integer division `//` truncates toward zero for all four sign combinations of dividend and divisor.
  • elm-core / StandardA41IntDivisionWideTest
    `a // 1` is `a`, also for an `a` beyond 32 bits.
  • elm-core / StandardA42ZeroDivisorTest
    `3 // 0`, `modBy 0 3` and `remainderBy 0 3` are all `0`: the examples A Standard Definition of Elm? gives for ruling A42 in its initial dynamic basis.

Discussions

Discuss this basis entry·Search the discussions on GitHub

Discussions are on GitHub; one about this basis entry has [b:Basics.idiv] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.