Elm Exactly

Figuredynamic-basis-int

Figure 49, APPLY\APPLY on Int Values, in Section D.4.1 Int Arithmetic.

APPLY(add,m,n) = {norm(m+n)}APPLY(sub,m,n) = {norm(m−n)}APPLY(mul,m,n) = {norm(m⋅n)}APPLY(negate,n) = {norm(−n)}APPLY(idiv,m,n) = {norm(trunc(m/n))}if n≠0 = {0}if n=0APPLY(modBy,n,m) = {m−n⋅⌊m/n⌋}if n≠0 = {0}if n=0APPLY(remainderBy,n,m) = {m−n⋅trunc(m/n)}if n≠0 = {0}if n=0APPLY(pow,m,n) = {norm(mn)}if n≥0 = {1}if n<0 and m=1 = {(−1)n}if n<0 and m=−1 = {0}if n<0 and m∉{1,−1} \begin{array}{rcll} \APPLY(\kw{add},m,n) {\ }& = {\ }& \{\norm(m+n)\} {\quad}& \\ \APPLY(\kw{sub},m,n) {\ }& = {\ }& \{\norm(m-n)\} {\quad}& \\ \APPLY(\kw{mul},m,n) {\ }& = {\ }& \{\norm(m\cdot n)\} {\quad}& \\ \APPLY(\kw{negate},n) {\ }& = {\ }& \{\norm(-n)\} {\quad}& \\[1ex] \APPLY(\kw{idiv},m,n) {\ }& = {\ }& \{\norm(\dbtrunc(m/n))\} {\quad}& \text{if}\ n\neq 0\\ {\ }& = {\ }& \{0\} {\quad}& \text{if}\ n=0\\[1ex] \APPLY(\kw{modBy},n,m) {\ }& = {\ }& \{m-n\cdot\lfloor m/n\rfloor\} {\quad}& \text{if}\ n\neq 0\\ {\ }& = {\ }& \{0\} {\quad}& \text{if}\ n=0\\[1ex] \APPLY(\kw{remainderBy},n,m) {\ }& = {\ }& \{m-n\cdot\dbtrunc(m/n)\} {\quad}& \text{if}\ n\neq 0\\ {\ }& = {\ }& \{0\} {\quad}& \text{if}\ n=0\\[1ex] \APPLY(\kw{pow},m,n) {\ }& = {\ }& \{\norm(m^{n})\} {\quad}& \text{if}\ n\geq 0\\ {\ }& = {\ }& \{1\} {\quad}& \text{if}\ n<0\ \text{and}\ m=1\\ {\ }& = {\ }& \{(-1)^{n}\} {\quad}& \text{if}\ n<0\ \text{and}\ m=-1\\ {\ }& = {\ }& \{0\} {\quad}& \text{if}\ n<0\ \text{and}\ m\notin\{1,-1\} \end{array}
Figure 49: APPLY\APPLY on Int Values
Read it in its chapter·Permanent address: /standard/figures/dynamic-basis-int

Referred to from

Tests (0)

No test of the suite checks this figure yet.

Discussions

Discuss this figure·Search the discussions on GitHub

Discussions are on GitHub; one about this figure has [fig:dynamic-basis-int] 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.